Jquery 使用刷新令牌获取访问令牌office 365 rest api

Jquery 使用刷新令牌获取访问令牌office 365 rest api,jquery,ajax,rest,office365,Jquery,Ajax,Rest,Office365,在使用刷新令牌通过office 365 REST api获取访问令牌时,我发出了以下Jquery ajax请求 jQuery.ajax({ url: "https://outlook.office365.com/common/oauth2/token", type: "post", headers:{ "Content-Type":"application/x-www-form-urlencoded" }, data: { gran

在使用刷新令牌通过office 365 REST api获取访问令牌时,我发出了以下Jquery ajax请求

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)
    }
  })
我得到以下错误

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.
但是我能够使用相同的
refresh\u令牌和
客户端凭据通过
requests
库在python中发出相同的POST请求,并且无法理解为什么相同的POST请求不能通过
jQuery
工作。在此问题上的任何帮助都将不胜感激


谢谢这
http://outlook.office365.com
resource支持CORS,所以您不应该遇到这个问题。我发现了这一点,接受的答案表明jQuery修改了请求,因此CORS不起作用,并且您需要在执行请求之前编辑请求头

确保jQuery请求具有正确的头。

访问控制允许标头:x-request-with

一旦您使用CORS,请注意CORS使用隐式授权流,因此您将不会获得刷新令牌。
看一看,了解更多关于隐性赠款流动的信息

如果您是从localhost执行此操作,大多数浏览器不允许从localhost执行COR。研究如何在浏览器中找到合适的标志/配置,以便从localhost启用COR。Chrome有一些扩展名和标志可以设置。

我还尝试使用Chrome扩展名在Chrome浏览器上发布帖子,结果发现
404(未找到)
errorJavaScript无法向第三方域发出请求,因为存在问题,除非使用JSONP或CORS。在这种情况下,它们似乎不是。您需要使用服务器端代理为您发出请求。HTTP status 404 not found(未找到HTTP状态404)如何?这是相同的问题-如果您注意到上面发布的错误的最后一行:
响应的HTTP状态代码为404。
您能为我提供发出上述请求的正确方法吗-谢谢