mercredi 1 juillet 2015

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.

jQuery.ajax({
    url: "http://ift.tt/1Jwc0SJ",
    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: "http://ift.tt/1pxDOan"
    },
    success: function(response){
      console.log(response)
    }
  })

I get the following error

XMLHttpRequest cannot load
http://ift.tt/1Jwc0SJ. 
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

Aucun commentaire:

Enregistrer un commentaire