【问题标题】:Unable to create UserAgentApplication with Microsoft Authentication library in a node project无法在节点项目中使用 Microsoft 身份验证库创建 UserAgentApplication
【发布时间】:2021-03-11 18:17:12
【问题描述】:

我正在尝试使用 @azure/msal-node 库在我的节点项目中创建一个 UserAgentApplication,但我收到一个错误 TypeError: Msal.UserAgentApplication不是构造函数。下面是我的详细代码和错误响应。

    const Msal = require("@azure/msal-node");

    const config = {
    auth: {
      clientId: "xxx-xxxx-xxxx",
      authority:"https://login.microsoftonline.com/xxxx-xxxxx",
      validateAuthority: true,
      postLogoutRedirectUri: "https://localhost:3000",
      redirectUri: "https://localhost:3000/app",
      navigateToLoginRequestUrl: true,
    },
  };

  const maslAuthorize = new Msal.UserAgentApplication(config);

  module.exports = maslAuthorize;

错误响应:

const maslAuthorize = new Msal.UserAgentApplication(config); TypeError: Msal.UserAgentApplication 不是构造函数

【问题讨论】:

  • 你不能在@azure/msal-node上使用UserAgentApplication考虑使用PublicClientApplication
  • 怎么样?你的问题解决了吗?

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


【解决方案1】:

正如@fortunee 所说,UserAgentApplication 不是@azure/msal-node,您应该使用ConfidentialClientApplicationPublicClientApplication 来登录用户。

您可以找到所有@azure/msal-node OAuth 2.0 流程示例代码here

【讨论】:

    猜你喜欢
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 2015-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-27
    • 1970-01-01
    相关资源
    最近更新 更多