Home  >  Q&A  >  body text

Angular 13 - BrowserAuthError: interaction_in_progress: Interaction in progress detected

The following error occurred when logging out and immediately trying to log back in. Only closing the browser seems to resolve the issue. So I'm assuming this is some kind of caching issue, but I can't seem to find a way around it.

This is the login code I am currently using:

async signIn() {
    // console.log(this.appMSALObj)
    var _this = this;
    await this.appMSALObj.loginPopup(settings.loginRequest)
      .then(function(response) {
        //console.log("authService: login complete")
        _this.selectAccount();
        //console.log(_this.account)
        _this.router.navigate(['/home'])
      })
      .catch(error => {
        console.error(error);
      });
  }

It never enters the selectAccount function.

msalConfig is set to use localStorage and the storeAuthStateInCookie flag is false.

P粉176203781P粉176203781206 days ago400

reply all(1)I'll reply

  • P粉066224086

    P粉0662240862024-03-28 10:37:10

    A bit late to answer, but I'll give it a try.

    According to docs This happens when the first operation has not completed yet and the second operation is triggered. For example:

    loginPopup();
    acquireTokenPopup();

    In this case, interaction_in_progress occurs. You can easily prevent this by waiting for:

    await msalInstance.loginPopup();
    await msalInstance.acquireTokenPopup();

    In some cases, this does not solve the problem. In my case, missing <app-redirect></app-redirect> could also cause this error. It must be placed in your index.html:

    
      
      
    

    Interesting thing to note: If you force login for every route mentioned in app-routing.module.ts, even if you don't use <app-redirect>< ;/app-redirect> and it still works without errors

    reply
    0
  • Cancelreply