SasiKiran SasiKiran - 1 year ago 249
reST (reStructuredText) Question

using refresh token to get access token office 365 rest api

While using the refresh token to get an access token through office 365 REST api I made the following Jquery ajax request.

url: "",
type: "post",
data: {
grant_type: "refresh_token",
refresh_token: access_data['refresh_token'],
client_id: consumer_key,
client_secret: consumer_secret,
resource: ""
success: function(response){

I get the following error

XMLHttpRequest cannot load
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
library using same
client credentials
and am unable to figure out why the same POST request does not work through
. Any help on this issue is appreciated.


Answer Source

The resource supports CORS, so you shouldn't be running into this problem. I found this question on Stack Overflow and the accepted answer suggests that jQuery alters the request so that CORS doesn't work and that you need to edit the request headers before executing it.

Make sure your jQuery request has the correct header. Access-Control-Allow-Headers: x-requested-with

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download