I'm using ajax to consume a web service.
My first request is a POST to get the auth token. (It's working.) But the second request is showing "401 (Unauthorized)". What could be the problem here?
PS. I'm using CORS extension on Chrome. If I disable that I get "No 'Access-Control-Allow-Origin' header is present on the requested resource"
When I use the same token on Postman(disabling SSL) my request is successful. The same token also works with python "requests.get(urlShow, headers=bpHeader, verify=False)".
$.ajax({
type: 'POST',
url: 'url',
data: {"authType" : "password", "username" : "<username>", "password" : "<password>", "tenant" : "<tenant>"},
success: function(bpResponse){
var bpAuth = "Bearer " + bpResponse.token;
console.log(bpAuth);
$.ajax({
type: "GET",
url: 'url',
headers: {"Accept": "application/json", "Authorization": bpAuth},
success: function(bpResources){
console.log(bpResources);
}
});
}
});
That's the console log I get: