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.

Interactive state still set in session storage on logoutRedirect

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

2.28.3

Wrapper Library

Not Applicable

Wrapper Library Version

None

Public or Confidential Client?

Public

Description

After upgrade from version 2.21.0 to 2.28.3. I’m unable to login again after logoutRedirect is called and browser is redirected to the login page. I see in the browsers session storage the key msal.interaction.status is set, On removal I can then login again.

I have a gif showing this issue but has private information shown, Please let me know if it would be of use to share with you.

Error Message

{
    "errorCode": "interaction_in_progress",
    "errorMessage": "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.",
    "subError": "",
    "name": "BrowserAuthError"
}

Msal Logs

No response

MSAL Configuration

{
  auth: {
    clientId: `${AUTH_CLIENT_ID}`,
    authority: `${AUTH_AUTHORITY_URI}/${AUTH_TENANT_ID}`,
    redirectUri: `${window.location.origin}/Redirect`,
    postLogoutRedirectUri: `${window.location.origin}`,
  },
  cache: {
    cacheLocation: BrowserCacheLocation.SessionStorage,
    storeAuthStateInCookie: false,
  },
}

Relevant Code Snippets

public logout(): Promise<void> {
  return this._client.logoutRedirect({ account: this.activeAccount });
}

Reproduction Steps

  1. Login to app using loginPopup
  2. Logout using logoutRedirect
  3. Attempt to login again using loginPopup (Receive error above)

Expected Behavior

Able to login again after returning to the login page.

Identity Provider

Azure B2C Basic Policy

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge

Regression

@azure/msal-browser 2.28.3

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
eglavincommented, Oct 3, 2022

Ok, I’m realising now that I’m missing a call to handleRedirectPromise in my init function which I see now in these docs https://learn.microsoft.com/en-gb/azure/active-directory/develop/msal-js-initializing-client-applications#initialize-msaljs-2x-apps

My original implementation was based of this repo: https://github.com/Azure-Samples/ms-identity-javascript-react-spa-dotnetcore-webapi-obo/blob/master/ProfileSPA/src/utils/authProvider.js#L36

Which only calls the handleRedirectPromise if its used in Internet Explorer. I wonder was there a change to the logic since 2.21.0+ ? Any way I think I have that in hand now, just need to refactor the init function to ensure handleRedirectPromise is called before app is ready!

Thanks for you help Hector!

1reaction
hectormmgcommented, Sep 26, 2022

@eglavin thanks for raising this issue. I’ll start investigating and update you when I can reproduce this behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Single-page application: Sign-in and Sign-out - Microsoft Learn
Sign-out with a redirect. MSAL.js provides a logout method in v1, and logoutRedirect method in v2 that clears the cache in browser storage...
Read more >
BrowserAuthError: interaction_in_progress: Interaction is ...
Looks into session storage for key msal.[clientId].interaction.status and other temp values required for redirection process.
Read more >
Window.sessionStorage - Web APIs - MDN Web Docs
The read-only sessionStorage property accesses a session Storage object for the current origin. sessionStorage is similar to localStorage; ...
Read more >
okta-auth-js/README.md at master - GitHub
Returns the stored URI string stored by setOriginal. An OAuth state parameter is optional. If no value is passed for state , the...
Read more >
PublicClientApplication | microsoft-authentication-libraries-for-js
Silently acquire an access token for a given set of scopes. ... a user account is added or removed from localstorage in a...
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