首页 文章

无法加载https://login.microsoftonline.com/common/oauth2/v2.0/token

提问于
浏览
1

我从这个网址获取代码后,我正在尝试使用Outlook REST API获取令牌 https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize

我在axios上使用了 POST 请求,但问题是我收到了这个错误:

对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头 . 因此不允许Origin'http:// localhost:3000'访问 .

我的Axios帖子是这样的:

return Axios({
    method: 'post',
    url: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Access-Control-Allow-Origin':'*', Content-Type, origin, authorization, accept, client-security-token"
    },
    data: {
        'client_id': 'xxxxxx',
        'scope': 'calendars.readwrite',
        'code': encodeURIComponent('000000000'),
        'redirect_uri': encodeURIComponent('http://localhost:3000/storeprofile/xxxxxxxxx/outlook-scheduler'),
        'grant_type': 'authorization_code',
        'client_secret': encodeURIComponent('xxxxxxxxxx')
    };,
    responseType: 'json'
    }).then((response) => {
        console.log('token response: ', response);
    });

我得到 200 状态,但看不到我应该在响应中得到的令牌 . 响应应该是 json 但仍然没有 .

有人可以指导我吗?先感谢您!

1 回答

相关问题