Angular JS - $ http not sending headers

As the name implies, I need to transfer the authorization token, but when I check the network console, I get 403, because there is no confirmation and authorization there. NOTE. I removed the authorization token for this example.

$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; }); 

Does this sound like the correct syntax? What is wrong here?

EDIT: added XHR snapshot

enter image description here

EDIT: 2. Here is my network traffic, HAR through a bin bundle:

http://pastebin.com/fiFngZSy

+6
source share
1 answer

setting custom headers in XHR requests triggers a pre-validation request.

I bet you see an OPTIONS request without an Authorization header, and the corresponding response whose Access-Control-Allow-Headers value is not displayed Authorization , or the API does not even allow unauthorized OPTIONS requests.

I don't know stubhub api, but does CORS-compatible responses return?

+1
source

Source: https://habr.com/ru/post/977923/


All Articles