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

前端 未结 6 1967
孤街浪徒
孤街浪徒 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:36

    You can always watch for the requests being made using the developer console in your browser and see the difference in the request.

    But by looking at your jquery code &grant_type=password is being passed in the body not the querystring so the $http call should be

    $http({ method: 'POST', url: '/token', data: { username: $scope.username, password: $scope.password ,grant_type:password} }).success(function (data, status, headers, config) {

提交回复
热议问题