我正在嘗試使用 react-native-app-auth 包通過 microsoft office 365 對我的 ios 和 android 應用程式進行身份驗證,但不確定它為什么不回傳令牌。
這是我正在使用的配置:
const config = {
issuer:
'https://login.microsoftonline.com/{tenant-id}/v2.0',
clientId: '{client-id}',
redirectUrl: 'msauth.org.xxx.xxx://auth', // I got this from Azure
scopes: ['openid', 'profile', 'email', 'offline_access'],
};
我也嘗試過以下配置
const config = {
clientId: AuthConfig.appId,
warmAndPrefetchChrome: true,
redirectUrl: 'msauth.org.xxx.xxx://auth',
scopes: AuthConfig.appScopes,
additionalParameters: {prompt: 'select_account'},
serviceConfiguration: {
authorizationEndpoint:
'https://login.microsoftonline.com/'
AuthConfig.tenantId
'/oauth2/v2.0/authorize',
tokenEndpoint:
'https://login.microsoftonline.com/'
AuthConfig.tenantId
'/oauth2/v2.0/token',
},
};
這是代碼:
const loginWithOffice365 = async () => {
try {
let result = await authorize(config);
console.log('result', result); // This is not showing any result and not even printing any error
} catch (error) {
console.log('error', error);
}
}
我已在 Azure 中正確注冊了應用程式,這是重定向 url 螢屏截圖

它進入office 365頁面,我可以輸入我的憑據,它說你準備好登錄,我點擊繼續,一旦我這樣做,它就會回傳登錄頁面。我不確定我的重定向 URL 是否正確,因為我正在嘗試列印我應該從 Microsoft 取回的令牌。
我只是想列印訪問令牌。你能幫忙告訴我如何解決這個問題嗎?
uj5u.com熱心網友回復:
您的重定向網址應為 msauth.org.xxx.xxx://auth/
你只是缺少一個額外的'/'
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/497192.html
上一篇:如何在React中創建具有4個不同資料端點的重繪按鈕?
下一篇:無效的鉤子呼叫反應鉤子
