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

前端 未结 6 1919
孤街浪徒
孤街浪徒 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条回答
  •  猫巷女王i
    2021-02-04 02:42

    Similar to achinth, but you can still use the $http.post method (+ data is escaped)

    $http.post(loginUrl, "userName=" + encodeURIComponent(email) +
                         "&password=" + encodeURIComponent(password) +
                         "&grant_type=password"
    ).success(function (data) {
    //...
    

提交回复
热议问题