[英]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.