简体   繁体   中英

I am not able to login using MSAL angular . Please find issue details below

在此处输入图像描述

"@azure/msal-angular": "^2.0.1", "@azure/msal-browser": "^2.15.0",

this.msalBroadcastService.msalSubject$
.pipe(
takeUntil(this.\_destroying$)
).subscribe(val =\> console.log('SUBJEECT', val));

    this.msalBroadcastService.inProgress$
      .pipe(
        tap((status: InteractionStatus) => console.log('MSAL STATUS', status)),
        filter((status: InteractionStatus) => status === InteractionStatus.None),
        takeUntil(this._destroying$)
      )
      .subscribe((val) => {
        this.setLoginDisplay();
      })
    
      this.login()

ERROR Error: Uncaught (in promise): BrowserAuthError: interaction_in_progress: Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. For more visit: aka.ms/msaljs/browser-errors.

BrowserAuthError: interaction_in_progress:

  • The above error happens when one entity (in our case it is this.msalBroadcastService.msalSubject$ ) is still running while other entity( this.msalBroadcastService.inProgress$ ) is trying to run. To rectify the error add the await keyword in front them.

The code will look like this -

   await  this.msalBroadcastService.msalSubject$
              .pipe(takeUntil(this.\_destroying$)).subscribe(val =\> console.log('SUBJEECT', val));
   await  this.msalBroadcastService.inProgress$
              .pipe(
                    tap((status: InteractionStatus) =>  console.log('MSAL STATUS', status)),
                    filter((status: InteractionStatus) =>  status === InteractionStatus.None),
                    takeUntil(this._destroying$)
                    )
              .subscribe((val) => {
                                    this.setLoginDisplay();
                                  }
                         )
    
    await  this.login()

refer the following documentation:

BrowserAuthError: interaction_in_progress:

angular spa with sign in

MSAL for angular

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM