javascript - Microsoft Online Auth 没有 'Access-Control-Allow-Origin' header

标签 javascript cors microsoft-graph-api

我正在尝试使用 Microsoft graph OAuth 端点发出一个简单的请求来获取访问 token 。当我发送下面的简单请求时,我得到了

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:8080/myapprunninglocally' is therefore not allowed access.**"

var xhttp = new XMLHttpRequest();
xhttp.open("GET", "https://login.microsoftonline.com/common/oauth2/authorize?client_id=<client_id>&scope=wl.signin%20wl.calendars_update&response_type=token&redirect_uri=localhost:8080/myapprunninglocally", true);
xhttp.send();

我还使用 Microsoft Azure Directory 注册了此应用程序,请求了所有权限,并使用了委托(delegate)的 client_id

我已经阅读了 CORS 并且我知道跨源策略但是,我知道有一些 API 公开了端点,这些端点在它们的响应头。有人能帮忙吗?

最佳答案

您将无法从客户端运行它。部分 CORS 设置要求 microsoftonline.com 将您的域添加到其支持 CORS 的白名单中。

我建议你在你的服务器上调用一个服务,然后请求服务器到服务器。

关于javascript - Microsoft Online Auth 没有 'Access-Control-Allow-Origin' header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38317973/

相关文章:

javascript - 如何检测 PDF 数据对象是否在 html 对象中加载/播放/有效

JavaScript 多重按键

javascript - Bootstrap Carousel 不适用于 Angular ng-route

javascript - 从 Vue js 通过 axios 调用 google maps elevation api 时如何修复跨域读取阻塞?

azure - 通过Az模块创建azure应用程序并使用powershell分配API权限

javascript - Angular : unexpected request (ngMockE2E - $httpBackend)

python-2.7 - 如何在python中启用CORS

jquery - 请求的资源 node.js 上不存在 Access-Control-Allow-Origin header

office365 - Microsoft Graph - 修补日历事件时出现 PopAuthenticatorInvalidSignature 错误

microsoft-graph-api - 如何使用 Microsoft 图形 API 以编程方式设置团队图片?