从这个 url 获得代码后,我正在尝试使用 Outlook REST API 获取令牌
https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize
我对 axios 使用了
POST
请求,但问题是我收到了这个错误:
对预检请求的响应未通过访问控制检查:请求的资源上不存在“Access-Control-Allow-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
,但仍然没有。
有人可以指导我吗?提前谢谢你!