我正在嘗試從 Microsoft Azure 檢索 OAuth v2 令牌,以允許我的 API 訪問 SMTP 服務器(嘗試從此處實作選項 1 )。我正在嘗試使用該msal-node庫。
我已經注冊了我的 API 并有一個令牌端點,格式如下:
const tokenEndpoint = https://login.microsoftonline.com/{{tenantID}}/oauth2/v2.0/token
我有以下代碼:
const msalConfig: Configuration = {
auth: {
authority: tokenEndpoint,
clientId: clientId,
clientSecret: clientSecret, // Using Client Secret Value
}
};
const tokenScopes = ['https://outlook.office.com/SMTP.Send'];
export const getAuth = async () => {
const cca = new ConfidentialClientApplication(msalConfig);
try {
const authResponse: AuthenticationResult = await cca.acquireTokenByClientCredential({
scopes: tokenScopes
});
console.log(`Auth Response: ${authResponse.accessToken}`);
} catch (err) {
console.log(`Error (getAuth): ${err}`);
}
};
運行時getAuth,我收到以下錯誤:
Error (getAuth): ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again.
Detail: ClientAuthError: openid_config_error: Could not retrieve endpoints. Check your authority and verify the .well-known/openid-configuration endpoint returns the required endpoints. Attempted to retrieve endpoints from: https://login.microsoftonline.com/{{id}}/oauth2/v2.0/token/v2.0/.well-known/openid-configuration
我已經多次檢查了我的端點 - 我可能做錯了什么?
uj5u.com熱心網友回復:
根據檔案here,權限端點應該是https://login.microsoftonline.com/{{tenantID}}/.
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/441693.html
標籤:节点.js 打字稿 天蓝色 oauth-2.0 msal
