reactjs - 将应用程序从react-azure-adb2c移植到react-aad

标签 reactjs azure azure-active-directory adal

我正在使用 Azure AD B2C。我需要一些 React 库来对我的 React.js 应用程序中的用户进行身份验证。

我从react-azure-adb2c开始。登录和注销等主要场景对我来说效果很好。但是,图书馆所有者停止支持该图书馆,因此我需要寻找其他图书馆。

使用 react-aad 进行实验。 我使用了这个例子,得到了一个很好的页面,建议弹出或重定向登录。然而,两者都不起作用。我的配置很可能包含错误。 如果我不提供权限,我将获得 microsoft auth 页面,而不是为我的租户提供的。如果我提供'https://x5aaas.b2clogin.com/x5aaas.onmicrosoft.com ',按照 this post 的指示,我在控制台中看到错误“endpoints_resolution_error:端点无法解析”。

似乎存在一些配置错误:

provider={
    new MsalAuthProviderFactory({
        authority: 'https://x5aaas.b2clogin.com/x5aaas.onmicrosoft.com', 
        clientID: 'a1568977-3095-4bf6-a6d6-c10c87658488',
        scopes: ['https://x5aaas.onmicrosoft.com/ui/use'],
        type: LoginType.Redirect,
        persistLoginPastSession: true,
        postLogoutRedirectUri: window.origin.location,
    })
}

我使用带有类型脚本的基本 React 应用程序,使用

创建
npx create-react-app <appName> --typescript

这里可能出了什么问题?

最佳答案

权限值不正确。您应该使用https://login.microsoftonline.com/tfp/<your-tenant-name>.onmicrosoft.com/<your-sign-in-sign-up-policy>

your-sign-in-sign-up-policy的值是策略的名称。

enter image description here

关于reactjs - 将应用程序从react-azure-adb2c移植到react-aad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55645155/

相关文章:

node.js - react 与 Node (Multer): Image is not found by path while it exists on that path

reactjs - 尝试导入错误 : 'Switch' is not exported from 'react-router'

azure - 如何使用 prependpath 在 azure-pipeline 中设置路径

.net - 获取 AzureRmResource : A parameter cannot be found that matches parameter name 'Tag'

windows - 使用联合用户登录 Windows 设备

azure - 使用 Azure 托管的 Godaddy 域电子邮件帐户

javascript - 如何将我的方法重写为 async/await?

azure - 如何在 Azure 数据工厂 v2 中运行 SQL 脚本?

azure - 如何使用 Microsoft OAuth 获取另一个资源的访问 token

javascript - 使用 "Styled-Components"创建 css 规则