Gar*_*uuk 7 http http-headers angularjs
正如标题所示,我需要传递授权令牌,但是当我检查网络控制台时,我得到的是403,因为接受和授权不存在.注意:我删除了此示例的授权令牌
$http({
url: 'http://api.stubhub.com/search/catalog/events/v2?title="san"',
dataType: 'json',
method: 'GET',
data: '',
headers: {
"Content-Type": 'application/json',
"Authorization": 'Bearer {token}'
}
}).success(function(response){
$scope.searchResponse = response;
}).error(function(error){
$scope.error = error;
});
Run Code Online (Sandbox Code Playgroud)
这似乎是正确的语法?这有什么不对?
编辑:添加了XHR截图
编辑:2.这是我的网络流量,HAR通过粘贴箱:
在 XHR 请求上设置自定义标头会触发预检请求。
我敢打赌,您会看到一个没有标头的 OPTIONS 请求,以及标头值未列出的Authorization
相应响应,或者 API 甚至不允许未经授权的 OPTIONS 请求。Access-Control-Allow-Headers
Authorization
我不知道 Stubhub api,但它是否返回符合 CORS 的响应?
归档时间: |
|
查看次数: |
2104 次 |
最近记录: |