简体   繁体   English

使用msal.js在角度spa上进行身份验证

[英]Authentication on angular spa using msal.js

my angular app has 1000s unique routes and users should be able to click on login button from any of those pages. 我的角度应用程序有1000个独特的路由,用户应该可以从任何这些页面点击登录按钮。 Have implemented msal.js basing on this sample : 基于此示例实现了msal.js:

https://github.com/Gimly/simpleAngularAzureB2C/blob/master/src/app/authentication.service.ts https://github.com/Gimly/simpleAngularAzureB2C/blob/master/src/app/authentication.service.ts

I am getting following error when calling login method: 调用login方法时出现以下错误:

AADB2C90006:+The+redirect+URI+' http://localhost:39579/unique-uri '+provided+in+the+request+is+not+registered+for+the+client+id+ AADB2C90006:+ +重定向+ URI +' http:// localhost:39579 / unique-uri '+提供+ + + +请求+ + +不+注册+ + + +客户端+ id +

Is there a way to get around this? 有办法解决这个问题吗?

Thanks! 谢谢!

By default, the Msal.UserAgentApplication constructor sets the "redirect_uri" request parameter to the current URL, which doesn't scale. 默认情况下,Msal.UserAgentApplication构造函数将“redirect_uri”请求参数设置为当前URL,该URL不会缩放。

The Msal.UserAgentApplication constructor accepts a "redirectUri" options argument that enables the "redirect_uri" request parameter to be set to a fixed URL (eg " http://localhost:39579/authcallback ") that is registered for the Azure AD B2C application. Msal.UserAgentApplication构造函数接受“redirectUri”选项参数,该参数允许将“redirect_uri”请求参数设置为为Azure AD B2C应用程序注册的固定URL(例如“ http:// localhost:39579 / authcallback ”) 。

Before MSAL generates the authentication request to Azure AD B2C, it writes the current URL (eg, " http://localhost:39579/unique-uri ") to storage and then redirects the user agent to the authentication endpoint. 在MSAL生成对Azure AD B2C的身份验证请求之前,它会将当前URL(例如,“ http:// localhost:39579 / unique-uri ”)写入存储,然后将用户代理重定向到身份验证端点。

At the "/authcallback" endpoint, you must create a new instance of Msal.UserAgentApplication, to handle the authentication response. 在“/ authcallback”端点,您必须创建Msal.UserAgentApplication的新实例,以处理身份验证响应。

After MSAL verifies the authentication response from Azure AD B2C, it reads the original URL from storage and then returns the user agent to this URL. 在MSAL验证Azure AD B2C的身份验证响应后,它会从存储中读取原始URL,然后将用户代理返回到此URL。

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

相关问题 Angular 8 与 Azure B2C 身份验证(使用 MSAL.js) - Angular 8 with Azure B2C Authentication (using MSAL.js) msal.js angular 6 SPA回调和错误处理 - msal.js angular 6 SPA callback and errors handling 使用B2C在Javascript / Angular 6 SPA应用程序中通过MSAL.JS注销的错误 - Error in Logout through MSAL.JS in Javascript / Angular 6 SPA application using B2C 如何在不使用 MSAL.js 的情况下处理 web api 和 angular 应用程序之间的 azure 访问令牌 - How to handle azure access token between web api and angular apps without using MSAL.js msal.js访问令牌中的自定义声明 - Custom claims in msal.js access token 使用 Azure AD B2C 从 Angular 应用程序和 msal.js 登录重定向用户 - Login redirect a user with Azure AD B2C from an Angular application and msal.js 使用 AAD 使用 MSAL.js 生成的令牌和 Connect-MicrosoftTeams -AadAccessToken cmdlet - Using the Token generated by AAD using MSAL.js, with Connect-MicrosoftTeams -AadAccessToken cmdlet MSAL.js protectedResourceMap - 需要说明将其设置为什么 - MSAL.js protectedResourceMap - explanation needed for what to set it to Msal.js:node_modules / msal / lib-commonjs / index没有导出的成员“用户” - Msal.js: node_modules/msal/lib-commonjs/index has no exported member 'User' Angular使用MSAL Service身份验证使用用户名和密码 - Angular using MSAL Service authentication using username and password
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM