gpt4 book ai didi

node.js - 端点解析错误 - OAuth v2 Azure - msal-node

转载 作者:行者123 更新时间:2023-12-03 04:47:56 26 4
gpt4 key购买 nike

我正在尝试从 Microsoft Azure 检索 OAuth v2 token ,以允许我的 API 访问 SMTP 服务器(尝试实现 here 中的选项 1)。我正在尝试使用 msal-node 库。

我已经注册了我的 API 并拥有以下格式的 token 端点:

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

我已经多次仔细检查了我的端点 - 我可能做错了什么?

最佳答案

基于文档here ,权限端点应为 https://login.microsoftonline.com/{{tenantID}}/

关于node.js - 端点解析错误 - OAuth v2 Azure - msal-node,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71434059/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com