我有一个 Angular 应用程序 ( v11.2.0 ),它使用 MSAL 进行身份验证。我最近升级到该库的 v2(@azure/msal-angular - ^2.1.1、@azure/msal-browser - ^2.22.0),并且由于 MSAL 更改而进行了一些重构。除了对用户进行身份验证并获取身份验证响应时之外,它的大部分工作方式与以前一样:该过程在成功获取身份验证响应之前循环大约 3 次,每次都会明显刷新应用程序。我看到的大致流程如下:
身份验证在我的 app.component.ts 中启动和处理:
ngOnInit() {
this.msalBroadcastService.inProgress$
.pipe(
filter((status: InteractionStatus) => status === InteractionStatus.None)
)
.subscribe(async () => {
if (!this.authenticated) {
await this.logIn();
}
})
this.msalService.handleRedirectObservable().subscribe({
next: (result: AuthenticationResult) => {
if (!this.msalService.instance.getActiveAccount() &&
this.msalService.instance.getAllAccounts().length > 0) …Run Code Online (Sandbox Code Playgroud)