【发布时间】:2017-05-12 11:57:26
【问题描述】:
我尝试在angularjs中申请
POST /api/oauth/token HTTP/1.1
Host: Myweb.com
Authorization: Basic Base64(client_id:client_secret)
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
像这样..
Var req = {
method: 'POST',
url: 'https://Myweb.com/api/oauth/token',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'basic YjBiZGNkZTQtNmE5OS00ZDE4LTg5ZWQtYasdYtek0MzkTWCXy1LTRmOTktNDk0MS1iNDY2LTc2NDysdYdfsdxMzFiYg=='
},
data: {
'grant_type':'client_credentials'
}
}
$http(req).then(function successCallback(response) {
console.log('Success');
}, function errorCallback(response) {
console.log('Failed');
});
结果总是失败,以及如何正确应用到 grant_type 部分? 请帮帮我
【问题讨论】:
-
您遇到什么错误?是JS错误,还是服务器错误?
-
没有 js 或服务器错误,我得到 Failed 响应。如何申请获取数据?
-
触发哪个回调,成功回调还是错误回调?
-
我收到错误回调
标签: javascript angularjs api oauth