简体   繁体   English

Angular 8 与 Azure B2C 身份验证(使用 MSAL.js)

[英]Angular 8 with Azure B2C Authentication (using MSAL.js)

I'm trying to create a basic authentication app (SPA) using Angular 8 with Azure B2C login.我正在尝试使用 Angular 8 和 Azure B2C 登录创建一个基本身份验证应用程序 (SPA)。 I'm using this sample here .我在这里使用这个示例。
I already configured the "app registration" for the SPA, but I'm not sure whats is the "Web API" in the sample.我已经为 SPA 配置了“应用程序注册”,但我不确定示例中的“Web API”是什么。 When I run the project I can login but after redirect to Angular I got the following error:当我运行项目时,我可以登录,但在重定向到 Angular 后,我收到以下错误:

The application with ID '<MY_CLIENT_ID>' cannot get an ID token either because the openid scope was not provided in the request or the application is not authorized for it.

Can someone help me, please?有人能帮助我吗?

Thank you谢谢

While registering your application in the Azure AD B2C you need to configure the consent for openid and offline_access permission.在 Azure AD B2C 中注册您的应用程序时,您需要为 openid 和 offline_access 权限配置同意。

在此处输入图像描述

If you missed this configuration you can enable this in App -> API Permissions- > Microsoft Graph-> Delegated Permissions -> openid如果您错过了此配置,您可以在 App -> API Permissions-> Microsoft Graph-> Delegated Permissions -> openid 中启用它

This permission helps you to sign in to app with your work or school account and allow the app to see basic user profile information此权限可帮助您使用工作或学校帐户登录应用,并允许应用查看基本用户个人资料信息

this sample has 2 methods of setup, either use their demo tenant, where you don't set anything, just run.此示例有 2 种设置方法,或者使用他们的演示租户,您无需设置任何内容,只需运行即可。 or if you are setting your own app registration in the spa, which it appears that you are, then you also need to set up the web api from a different sample, as per the readme, https://github.com/Azure-Samples/active-directory-b2c-javascript-nodejs-webapi so you need to set this up, then in the API permissions, MY APIs will show in the SPA app registration.或者,如果您在 spa 中设置自己的应用程序注册,看起来您就是这样,那么您还需要根据自述文件 Z5E056C500A1C4B6A7110.com/Azure/Z5E056C500A1C4B6A7110.com/Azure Samples/active-directory-b2c-javascript-nodejs-webapi所以你需要设置它,然后在 API 权限中,MY APIs 将显示在 SPA 应用程序注册中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Azure AD B2C 从 Angular 应用程序和 msal.js 登录重定向用户 - Login redirect a user with Azure AD B2C from an Angular application and msal.js 使用B2C在Javascript / Angular 6 SPA应用程序中通过MSAL.JS注销的错误 - Error in Logout through MSAL.JS in Javascript / Angular 6 SPA application using B2C 使用msal.js在角度spa上进行身份验证 - Authentication on angular spa using msal.js 在Angular 4.5 Service中未定义的Msal用于Azure B2C身份验证 - Msal undefined in Angular 4.5 Service for Azure B2C authentication 使用Azure AD B2C时向Angular SPA和MSAL添加角色 - Adding roles to Angular SPA and MSAL when using using Azure AD B2C redirect_uri_mismatch Azure AD B2C,角度使用MSAL - redirect_uri_mismatch Azure AD B2C with angular using MSAL 如何在不使用 MSAL.js 的情况下处理 web api 和 angular 应用程序之间的 azure 访问令牌 - How to handle azure access token between web api and angular apps without using MSAL.js 来自 Angular 应用程序和 msal 的 Azure AD B2C:加载自定义 UI Html - Azure AD B2C from an Angular application and msal: Loading customized UI Html Angular Azure Active Directory B2C 身份验证 - CORS 问题 - Angular Azure Active Directory B2C Authentication - CORS issue 登录到应用程序后,带有MSAL和Angular的Azure AD B2C会立即重定向到登录页面 - Azure AD B2C with MSAL and Angular redirects to login page immediately after logging into the app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM