.NET Web API 2 OWIN Bearer Token Authentication

前端 未结 2 666
有刺的猬
有刺的猬 2020-12-22 16:00

I\'m implementing a Web API 2 service architecture in my .NET web application. The client consuming the requests is pure javascript, no mvc/asp.net. I\'m using OWIN to try

2条回答
  •  一向
    一向 (楼主)
    2020-12-22 16:16

    You can configure it with your angular application module. So authorization token will be set as header for every http request.

    var app = angular.module("app", ["ngRoute"]);
    app.run(function ($http) {
    
         $http.defaults.headers.common.Authorization = 'Bearer ' + token.accessToken;
    
    });
    

提交回复
热议问题