question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to recover from BrowserAuthError: interaction_in_progress? Logout now throws this error

See original GitHub issue

Library

  • @azure/msal-browser@2.13.0
  • @azure/msal-angular@2.0.0-beta.2

Framework

  • Angular

Description

In very rare, hard to reproduce cases, we see the BrowserAuthError: interaction_in_progress error. I’m aware of the FAQ and this error usually does not happen. However, I assume that if the user quits the browser in the middle of the process or something similar, it can happen. We therefore implemented an error handler, that would call the logout function to clear the state and have the user recover from this situation.

Now, with the recent upgrade this no longer works, because initializeLogoutRequest now throws this error. I can see that the “Interaction in progress” check was added to the logout function in this commit: https://github.com/AzureAD/microsoft-authentication-library-for-js/commit/3e8bfa2f4107241c35bedccd8e691009982d3ccb

If it’s no longer possible to logout the user, how can we recover from this situation? Currently the only option is to ask the user to clear cookies/cache. This is a very bad user experience…

@tnorling Can this change be reverted? If not, how else to recover?

Error Message

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.
    at BrowserAuthError.AuthError [as constructor] (http://localhost:4200/vendor.js:168843:24)
    at new BrowserAuthError (http://localhost:4200/vendor.js:175467:28)
    at Function.push.u8tD.BrowserAuthError.createInteractionInProgressError (http://localhost:4200/vendor.js:175534:16)
    at PublicClientApplication.push.u8tD.ClientApplication.initializeLogoutRequest (http://localhost:4200/vendor.js:179418:36)
    at PublicClientApplication.<anonymous> (http://localhost:4200/vendor.js:178875:51)

Expected behavior

Logout should always work and always clear up any in progress state. If this is not intended, please provide a method to clear the state so that we can recover from a broken login.

Identity Provider

  • Azure AD

Browsers/Environment

  • Chrome

Regression

  • Did this behavior work before? Version: "@azure/msal-browser": "^2.12.1",

Security

  • Is this issue security related?

Source

  • Customer request

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tnorlingcommented, Mar 29, 2021

@restfulhead This means that handleRedirectPromise isn’t being called on page load or isn’t finished before attempting to login again. handleRedirectPromise will clear in progress state when returning from a back button or when reloading the page.

Please read these docs and make sure you’re either using the MsalRedirectComponent or are calling handleRedirectObservable on every page that will call loginRedirect or return from a redirect

0reactions
restfulheadcommented, Mar 29, 2021

Oh I see. I was calling handleRedirectObservable() when returning from the redirect, but I missed the fact that I need to call it before the redirect as well. Changing my code to this.msalAuth.handleRedirectObservable().pipe(concatMap(() => this.msalAuth.loginRedirect({...}))) fixes the issue with the back button.

(I cannot simply add <app-redirect> to every page as the documentation suggests, because we support multiple identity providers and MSAL is not always active…)

This solves my issue. @tnorling Thank you so much for your prompt help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

BrowserAuthError: interaction_in_progress: Interaction is ...
If such key exist and its value equals 'interaction_in_progress' error will be thrown. Creates entry in session storage msal.
Read more >
After logout, in the same tab, user cannot login, and ... - GitHub
Click "go back" button in the browser. Then call login , but nothing happened with the exception. If the user opens a new...
Read more >
interaction_in_progress" in SPA with MSAL redirect and iframe
Getting "BrowserAuthError: interaction_in_progress" in SPA with MSAL redirect and iframe. I have a react SPA that uses MSAL and Azure AD B2C ...
Read more >
Renovate Bot Package Diff
Throw BrowserAuthError when fetch fails # 3146 (thomas.norling@microsoft.com). 17. + - Fix errors thrown on cache lookups when reading non-msal cache values ...
Read more >
angular msal refresh token | The AI Search Engine You Control
Use msalService.login and msalService.logout to well, log the user in or out. ... Error: Uncaught (in promise): BrowserAuthError: interactioninprogress: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found