.NET Web API 2 OWIN Bearer Token Authentication

前端 未结 2 658
有刺的猬
有刺的猬 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;
    
    });
    
    0 讨论(0)
  • 2020-12-22 16:19

    Resolved by setting header 'Authorization' with Bearer + token like:

    $http.defaults.headers.common["Authorization"] = 'Bearer ' + token.accessToken;
    
    0 讨论(0)
提交回复
热议问题