While using the refresh token to get an access token through office 365 REST api I made the following Jquery ajax request.
jQuery.ajax({
url: "https://outlook.office365.com/common/oauth2/token",
type: "post",
headers:{
"Content-Type":"application/x-www-form-urlencoded"
},
data: {
grant_type: "refresh_token",
refresh_token: access_data['refresh_token'],
client_id: consumer_key,
client_secret: consumer_secret,
resource: "https://outlook.office365.com"
},
success: function(response){
console.log(response)
}
})
I get the following error
XMLHttpRequest cannot load
https://outlook.office365.com/common/oauth2/token.
No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost' is therefore not allowed access.
The response had HTTP status code 404.
But I was able to make the same POST request in python through requests
library using same refresh_token
and client credentials
and am unable to figure out why the same POST request does not work through jQuery
. Any help on this issue is appreciated.
Thanks