端点解析错误 - OAuth v2 Azure - msal-node
Endpoints Resolution Error - OAuth v2 Azure - msal-node
我正在尝试从 Microsoft Azure 检索 OAuth v2 令牌以允许我的 API 访问 SMTP 服务器(尝试从 here 实施选项 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
我已经多次检查我的端点 - 我可能做错了什么?
根据文档 here
,权限端点应为 https://login.microsoftonline.com/{{tenantID}}/
。
我正在尝试从 Microsoft Azure 检索 OAuth v2 令牌以允许我的 API 访问 SMTP 服务器(尝试从 here 实施选项 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
我已经多次检查我的端点 - 我可能做错了什么?
根据文档 here
,权限端点应为 https://login.microsoftonline.com/{{tenantID}}/
。