How to get Access Token from ASP.Net Web API 2 via AngularJS $http?

前端 未结 6 1989
孤街浪徒
孤街浪徒 2021-02-04 02:12

I try like this:

$http({ method: \'POST\', url: \'/token\', data: { username: $scope.username, password: $scope.password, grant_type: \'password\' } }).success(f         


        
6条回答
  •  醉酒成梦
    2021-02-04 02:47

    I think, adding the header {headers: { 'Content-Type': 'application/x-www-form-urlencoded' } to your post request would do the trick. It should be something like this:

    $http.post(loginAPIUrl, data,
        {headers: { 'Content-Type': 'application/x-www-form-urlencoded' }})
    

提交回复
热议问题