【问题标题】:Getting an error when using msal in a nodejs backend在 nodejs 后端使用 msal 时出错
【发布时间】:2021-03-17 17:37:06
【问题描述】:

我为 Web 应用程序 (NodeJs) 下载了示例代码 from here,并将配置参数替换为我的应用程序的值。像这样:

const config = {
    auth: {
        clientId: "12345678901234567890",
        authority: "https://login.microsoftonline.com/09876543210987654321",
        clientSecret: "*****************",
        knownAuthorities: ["https://login.microsoftonline.com/09876543210987654321"
    ]
    },

当我运行应用程序时,我得到以下信息:

[Wed, 17 Mar 2021 17:30:24 GMT] :  : @azure/msal-node@1.0.0 : Info - getAuthCodeUrl called
[Wed, 17 Mar 2021 17:30:24 GMT] :  : @azure/msal-node@1.0.0 : Verbose - initializeRequestScopes called
[Wed, 17 Mar 2021 17:30:24 GMT] :  : @azure/msal-node@1.0.0 : Verbose - buildOauthClientConfiguration called
[Wed, 17 Mar 2021 17:30:24 GMT] :  : @azure/msal-node@1.0.0 : Verbose - createAuthority called
[Wed, 17 Mar 2021 17:30:24 GMT] :  : @azure/msal-node@1.0.0 : Verbose - Retrieving all cache keys
[Wed, 17 Mar 2021 17:30:24 GMT] :  : @azure/msal-node@1.0.0 : Verbose - Getting cache key-value store
{"errorCode":"endpoints_resolution_error","errorMessage":"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/09876543210987654321/v2.0/.well-known/openid-configuration","subError":"","name":"ClientAuthError"}

我不知道为什么会出现此错误,我没有连接到 VPN 或仅使用我的常规 ISP 的代理。

【问题讨论】:

  • 嗨 Jason,问题是我无法更改这些设置,因为它们是为我的组织设置的。
  • 正确的步骤是这样的。如果你没有权限设置,应该没办法。
  • 如果我的回复有帮助,请采纳为答案(点击回复旁边的标记选项将其从灰色切换为填写。),请参阅meta.stackexchange.com/questions/5234/…

标签: node.js azure-active-directory msal


【解决方案1】:

确保您已在门户上配置以下设置。


提示

如果我的解决方案没有生效,请在隐私模式下打开浏览器试一试,排除浏览器缓存的因素。如果还是不行,请刷新几次。


我的项目中的代码

index.js 文件。

auth: {
    clientId: "clientID",
    authority: "https://login.microsoftonline.com/tenantID",
    clientSecret: "yoursecret",
    knownAuthorities: ["https://login.microsoftonline.com/tenantID"]
},

它对我有用。

【讨论】:

    【解决方案2】:

    就我而言,这是自签名证书的问题。我的应用程序试图调用 '.well-known/openid-configuration' GET 端点,但它被阻止了。解决方法是将 "NODE_TLS_REJECT_UNAUTHORIZED": "0" 添加到我的环境变量中。

    【讨论】:

      猜你喜欢
      • 2016-04-07
      • 1970-01-01
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-28
      • 2015-09-20
      • 2018-05-14
      相关资源
      最近更新 更多