1

I'm getting the following error when logging out and immediately trying to log back in. Only closing the browser seems to fix the issue. So I'm assuming it's some sort of caching issue but I can't seem to figure out a way around it.

Here is the sign-in code I'm 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 makes it to the selectAccount function.

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

CStreet
  • 365
  • 1
  • 5
  • 20
  • you can also use the logoutSilently method to log out without removing the auth state from localStorage. This will allow you to log back in immediately without getting the error. – Sourav Jun 01 '23 at 10:35

1 Answers1

0

A little late for an answer but ill give it a try.

According to the docs this happens when a second action is triggered while the first isn't finished yet. For Example:

loginPopup();
acquireTokenPopup();

In this case interaction_in_progress occures. You can easily prevent this by awaiting these actions:

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

I some cases this doesnt fix the issue. In my case it was a missing <app-redirect></app-redirect> could led to this error as well. It must be placed right in your index.html:

<body>
  <app-root></app-root>
  <app-redirect></app-redirect>
</body>

Funny thing to notice: If you enforced a login for every of your routes mentioned in app-routing.module.ts it still works without error even if you dont use <app-redirect></app-redirect>

Felix Gerber
  • 1,615
  • 3
  • 30
  • 40