Azure AD B2C MSAL.js Angular BrowserAuthError: no_cached_authority_error:

Jacques de Klerk 20 Reputation points
2023-05-09T13:26:38.1266667+00:00

Hi,

We are intermittently receiving a BrowserAuthError: no_cached_authority_error when redirected back to an Angular SPA from a sign up flow in Azure B2C. After the error is thrown, we get a BrowserAuthError: interaction_in_progress error when trying to login in again, and it seems the only way to resolve this is to refresh the browser window. Any insights or workarounds would be appreciated, thanks!

@angular/core: 15.2.0
@azure/msal-angular: 2.5.7
@azure/msal-browser": 2.37.0
Screenshot 2023-05-09 at 15.13.06

Screenshot 2023-05-09 at 15.13.23

Microsoft Security | Microsoft Entra | Microsoft Entra External ID
Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

Accepted answer
  1. Shweta Mathur 30,296 Reputation points Microsoft Employee Moderator
    2023-05-11T07:42:22.0466667+00:00

    Hi @Jacques de Klerk ,

    Thanks for reaching out.

    The no_cached_authority_error error happens if there isn't a cache entry for the authority for request. This can potentially happen if the temporary cache used by MSAL is cleared. In MSAL.js v2, all temporary cache values are stored in sessionStorage (token storage is based on the cache.cacheLocation setting). Can you please try debugging to figure out if there is a session storage entry for the authority value when this error is thrown?

    As a mitigation, can you try setting storeAuthStateInCookie to true for all users.

    While his piece of code will check the session storage for key and other temp values required for redirection process and if values exist and values are equal then it will through exception interaction_in_progress

    Redirection in application can be handled by invoking handleRedirectPromise() method in MSAL. This ensures that the token response from the server is properly handled, and temporary cache entries are cleaned up. To resolve, verify all async/await wherever you call this on page load.

    await msalInstance.handleRedirectPromise();  
      
     async signIn(){  
        // lines of code
    

    Similar issue on SO - https://stackoverflow.com/questions/68726691/browserautherror-interaction-in-progress-unable-to-fix-regardles-of-solution

    Hope this will help.

    Thanks,

    Shweta

    Please remember to "Accept Answer" if answer helped you.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.