使用msal.js在Angle Spa上进行身份验证 [英] Authentication on angular spa using msal.js

查看:195
本文介绍了使用msal.js在Angle Spa上进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的角度应用程序具有1000条独特的路线,用户应该能够从任何这些页面中单击登录按钮.基于此示例实现了msal.js:

my angular app has 1000s unique routes and users should be able to click on login button from any of those pages. Have implemented msal.js basing on this sample :

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

调用登录方法时出现以下错误:

I am getting following error when calling login method:

AADB2C90006:+ The + redirect + URI +' http://localhost:39579/unique-uri '+在+请求中提供的+ +未在+该+客户端+ ID +中注册

AADB2C90006:+The+redirect+URI+'http://localhost:39579/unique-uri'+provided+in+the+request+is+not+registered+for+the+client+id+

有没有办法解决这个问题?

Is there a way to get around this?

谢谢!

推荐答案

默认情况下,Msal.UserAgentApplication构造函数将"redirect_uri"请求参数设置为当前URL,但不会缩放.

By default, the Msal.UserAgentApplication constructor sets the "redirect_uri" request parameter to the current URL, which doesn't scale.

Msal.UserAgentApplication构造函数接受"redirectUri"选项参数,该参数允许将"redirect_uri"请求参数设置为固定URL(例如," http://localhost:39579/authcallback .

The Msal.UserAgentApplication constructor accepts a "redirectUri" options argument that enables the "redirect_uri" request parameter to be set to a fixed URL (e.g. "http://localhost:39579/authcallback") that is registered for the Azure AD B2C application.

在MSAL向Azure AD B2C生成身份验证请求之前,它会写入当前URL(例如," http://localhost:39579/unique-uri )存储,然后将用户代理重定向到身份验证端点.

Before MSAL generates the authentication request to Azure AD B2C, it writes the current URL (e.g., "http://localhost:39579/unique-uri") to storage and then redirects the user agent to the authentication endpoint.

在"/authcallback"端点,您必须创建一个新的Msal.UserAgentApplication实例,以处理身份验证响应.

At the "/authcallback" endpoint, you must create a new instance of Msal.UserAgentApplication, to handle the authentication response.

MSAL验证来自Azure AD B2C的身份验证响应后,它将从存储中读取原始URL,然后将用户代理返回到该URL.

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.js在Angle Spa上进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆