我正在使用Javascript从Azure刷新访问令牌,但它现在无法正常工作并且出现错误:
无法加载https://login.microsoftonline.com/common/oauth2/token:对预检请求的响应未通过访问控制检查:请求的资源上没有“Access-Control-Allow-Origin”标头。起源'
以下是我正在使用的代码:
var form_data = {
"client_id": "***",
"grant_type": "refresh_token",
"resource": "https://analysis.windows.net/powerbi/api",
"username": "**",
"password": "**",
"scope": "openid",
"client_secret": "**",
"refresh_token": "****"
};
var options = {
method: "post",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: form_data
}
return fetch("https://login.microsoftonline.com/common/oauth2/token", options).then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error("Server response wasn't OK");
}
}).then((json) => {
return json.token;
});
我该如何解决这个问题?