現在、https://login.microsoftonline.com/XXX/oauth2/tokenエンドポイントへポストリクエストを送信して、アプリケーションのアクセストークンとリフレッシュトークンを取得しようとしています。 axiosを使用してポスト要求をエンドポイントに送信すると、プリフライトはオフになりますが、応答は返されません。Azure ADプリフライトリクエストがデータを返さない
エラー:両方Axios要求を
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:3000' is therefore not allowed access.
:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:3000' is therefore not allowed access.
しかしaxiosポスト要求に異なるアプローチを使用して、それがデータを返しますが、何のプリフライトを持っていないし、別のエラーを与えます:
const data = new FormData();
data.append('grant_type', this.config.grant_type);
data.append('client_id', this.config.client_id);
data.append('code', localStorage.getItem('auth_code'));
data.append('redirect_uri', this.config.redirect_uri);
data.append('client_secret', this.config.client_secret);
data.append('resource', this.config.client_id);
axios.post(`https://login.microsoftonline.com/${this.config.tenant}/oauth2/token`, data);
方法2:
axios({
method: 'post',
contentType: 'application/json',
url: `https://login.microsoftonline.com/${this.config.tenant}/oauth2/token`,
data: {
grant_type: this.config.grant_type,
client_id: this.config.client_id,
code: localStorage.getItem('auth_code'),
redirect_uri: this.config.redirect_uri,
client_secret: this.config.client_secret,
resource: this.config.client_id
}
});
これはaxios要求自体またはエンドポイントに問題がありますか?