私の反応するネイティブアプリのログイン画面を作ろうとしていますが、Web APIから認証トークンを取得できません。React Native - asp.net web apiからトークンを取得できません
私は郵便配達員と一緒に試してみると、私はトークンを手に入れることができます。
投稿するには、apiとadiosを取得しようとしましたが、成功しませんでした。
これは私のコードをフェッチ
fetch("https://ahmetkocadogan.a2hosted.com/token", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded",
},
body: JSON.stringify({
grant_type: "password",
deviceId: "ahmet",
username: "ahmet",
password: "123456",
})
}).then(response => {console.log(response);})
.catch(error => {
console.log(error);
});
}
マイAPIトークンURLはされています - アプリケーション/ JSON、コンテンツタイプ - アプリケーション/ X-WWWの郵便配達中https://ahmetkocadogan.a2hosted.com/token
、私は受け入れるとして、ヘッダーを追加します。
と身体form.urlencoded: - パスワード、ユーザ名 - アフメット、パスワード - 123456とデバイス - grant_typeアフメット
をそして私はポストからトークンを取得おとこ。
アイデア?フェッチコードで何が問題になっていますか?