Skip to content

Why do I get interaction_in_progress for the following order of method calls? #7502

Open
@kudorgyozo

Description

@kudorgyozo

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.28.0

Wrapper Library

Not Applicable

Wrapper Library Version

none

Public or Confidential Client?

Public

Description

I don't know if this is a bug or not. The following order of method calls are not working:

//refresh page
addEventCallback();
initialize();
getActiveAccount();
getAllAccounts();
loginRedirect();

and the following, with an extra clear cache does work:

//refresh
addEventCallback();
initialize();
getActiveAccount();
getAllAccounts();

clearCache(); <======== this
loginRedirect();

This is not the actual code, not even pseudocode, this is just an ordered list of things I do with the msal.js library.
Am I doing something wrong?

This is in an angular app, and I'm intentionally not using any wrapper. (I've had many issues with the angular wrapper, at least this is working, more or less) What I have is just a service that calls the msal instance, and a component with a login, logout button, that uses the instance.

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 createBrowserAuthError (BrowserAuthError.mjs:272:10)
    at BrowserCacheManager.setInteractionInProgress (BrowserCacheManager.mjs:1049:15)
    at _StandardController.acquireTokenRedirect (StandardController.mjs:320:27)
    at _StandardController.loginRedirect (StandardController.mjs:1108:17)
    at _PublicClientApplication.loginRedirect (PublicClientApplication.mjs:230:28)
    at _AuthService.login (auth.service.ts:65:37)
    at _ProfileComponent.login (profile.component.ts:36:32)
    at ProfileComponent_Conditional_1_Template_button_click_0_listener (profile.component.html:3:56)
    at executeListenerWithErrorHandling (core.mjs:29245:12)
    at wrapListenerIn_markDirtyAndPreventDefault (core.mjs:29277:18)

MSAL Logs

Navigated to https://localhost:57429/profile
logging.service.ts:35 [LoggingService ctor] {logLevel: 0, consoleLogOnly: true}
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager - createKeyMaps called.
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Verbose - Event callback registered with id: 019456c8-8a39-73ae-8a69-08f04d6152fe
logging.service.ts:45 [DEBUG]: [Auth initInner start]
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - initialize called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback 019456c8-8a39-73ae-8a69-08f04d6152fe: msal:initializeStart
logging.service.ts:45 [DEBUG]: [msal event, status]  {eventType: 'msal:initializeStart', interactionType: null, payload: null, error: null, timestamp: 1736622770748} null
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Verbose - Claims-based caching is disabled. Clearing the previous cache with claims
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - Executing function clearTokensAndKeysWithClaims
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getTokenKeys called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getTokenKeys - No token keys found
core.mjs:20876 Angular is running in development mode.
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - Returning result from clearTokensAndKeysWithClaims
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback 019456c8-8a39-73ae-8a69-08f04d6152fe: msal:initializeEnd
logging.service.ts:45 [DEBUG]: [msal event, status]  {eventType: 'msal:initializeEnd', interactionType: null, payload: null, error: null, timestamp: 1736622770755} null
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getActiveAccount: No active account found
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getAccountKeys called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:50 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
logging.service.ts:45 [DEBUG]: [Auth initInner end]
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:55 GMT] : [019456c8-9b4b-73bd-875a-26e8bff8fa87] : @azure/[email protected] : Verbose - loginRedirect called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:55 GMT] : [019456c8-9b4b-73bd-875a-26e8bff8fa87] : @azure/[email protected] : Verbose - acquireTokenRedirect called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:55 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:55 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getAccountKeys called
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:55 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:55 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getTemporaryCache: Temporary cache item returned
msal.config.ts:52 [Sat, 11 Jan 2025 19:12:55 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback 019456c8-8a39-73ae-8a69-08f04d6152fe: msal:loginFailure
logging.service.ts:45 [DEBUG]: [msal event, status]  {eventType: 'msal:loginFailure', interactionType: 'redirect', payload: null, error: BrowserAuthError: interaction_in_progress: Interaction is currently in progress. Please ensure that…, timestamp: 1736622775116} none
logging.service.ts:72 [ERROR]: login error 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

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

auth: {
        clientId: environment.msalConfig.auth.clientId,
        authority: environment.b2cPolicies.authorities.signUpSignIn.authority,
        redirectUri: '/profile',
        postLogoutRedirectUri: '/home',
        knownAuthorities: [environment.b2cPolicies.authorityDomain]
    },
    cache: {
        cacheLocation: BrowserCacheLocation.LocalStorage
    },
    system: {
        allowNativeBroker: false, // Disables WAM Broker
        loggerOptions: {
            loggerCallback,
            logLevel: LogLevel.Trace,
            piiLoggingEnabled: true
        }
    }

Relevant Code Snippets

call these methods in this order
addEventCallback();
initialize();
getActiveAccount();
getAllAccounts();
loginRedirect();

Reproduction Steps

call these methods in this order, as mentioned above
addEventCallback();
initialize();
getActiveAccount();
getAllAccounts();
loginRedirect();

Expected Behavior

Login redirect should work

Identity Provider

Azure B2C Basic Policy

Browsers Affected (Select all that apply)

Chrome, Other

Regression

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋Awaiting response from the MSAL.js teamb2cRelated to Azure B2C library-specific issuesbug-unconfirmedA reported bug that needs to be investigated and confirmedmsal-browserRelated to msal-browser packagepublic-clientIssues regarding PublicClientApplicationsquestionCustomer is asking for a clarification, use case or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions