Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedirectHandler.initiateAuthRequest forces another login during msal:acquireTokenSuccess after successful login #7416

Open
1 of 2 tasks
jackskelly-ctrl opened this issue Nov 13, 2024 · 2 comments
Labels
b2c Related to Azure B2C library-specific issues bug-unconfirmed A reported bug that needs to be investigated and confirmed msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Author Feedback Awaiting response from issue author no-issue-activity Issue author has not responded in 5 days public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@jackskelly-ctrl
Copy link

jackskelly-ctrl commented Nov 13, 2024

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.0.25

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

None

Public or Confidential Client?

Public

Description

When B2C users are logging in for the first time, they are prompted with the desired flow and, apparently, successfully login. They are redirected to the redirectUri. Before the app loads, guard starts issuing acquireTokenSilent for the protected resources defined in the protectedResourceMap. After the first token request, Msal reinitiates auth, sending the user back to the login page. If the user navigates to the app URL, it's successfully logged in. Or it may decide to re-enter the login informations for the second time, which also leads to the expected outcome (a successful session).

Error Message

Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve. (a couple of times)

MSAL Logs

bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BrowserCrypto: modern crypto interface available
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Event callback registered with id: GUID
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:initializeStart
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Claims-based caching is disabled. Clearing the previous cache with claims
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getTokenKeys - No token keys found
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - MSAL Interceptor activated
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - getting scopes for endpoint
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - no active account, fallback to first account
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Info - Interceptor - 1 scopes found for endpoint
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - MSAL Interceptor activated
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - getting scopes for endpoint
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - no active account, fallback to first account
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Info - Interceptor - 1 scopes found for endpoint
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - MSAL Interceptor activated
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - getting scopes for endpoint
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - no active account, fallback to first account
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Info - Interceptor - 1 scopes found for endpoint
bootstrap.bundle.min.js:20570 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.

bootstrap.bundle.min.js:20570 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.

bootstrap.bundle.min.js:20570 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.

bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Guard - canActivate
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - MSAL Guard activated
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:initializeStart
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Claims-based caching is disabled. Clearing the previous cache with claims
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getTokenKeys - No token keys found
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:initializeEnd
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:handleRedirectStart
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - BroadcastService - msal:handleRedirectStart results in setting inProgress from startup to 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - initializeServerTelemetryManager called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - getRedirectResponseHash called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Hash contains known properties, returning response hash
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Current page is loginRequestUrl, handling response
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - handleResponse called, retrieved cached request
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Attempting to get cloud discovery metadata  from authority 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - The host is included in knownAuthorities. Creating new cloud 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Found cloud discovery metadata in authority configuration
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise has been called for the first time, storing the promise
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:initializeEnd
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Info - initialize has already been called, exiting early.
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Attempting to get endpoint metadata from authority 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Did not find endpoint metadata in the config... Attempting 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Did not find endpoint metadata in hardcoded values... 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - Authority.getEndpointMetadataFromNetwork: attempting to 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise has been called previously, returning the result from the first call
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - Guard - canActivate
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - MSAL Guard activated
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Info - initialize has already been called, exiting early.
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Info - initialize has already been called, exiting early.
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:17 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise has been called previously, returning the result from the first call
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : [email protected] : Verbose - RedirectHandler.handleCodeResponse called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [0193271f-df69-7d18-b51b-032290496a76] : @azure/[email protected] : Verbose - setCachedAccount called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.addAccountKeyToMap account key added
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager.getTokenKeys - No token keys found
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Info - BrowserCacheManager: addTokenKey - idToken added to map
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Info - BrowserCacheManager: addTokenKey - accessToken added to map
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:18 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:loginSuccess
bootstrap.bundle.min.js:18800 msalBroadcastService 1
bootstrap.bundle.min.js:18801 {eventType: 'msal:loginSuccess', interactionType: 'redirect', payload: {…}, error: null, timestamp: 1731528258487}
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectResponse returned result, login success
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:handleRedirectEnd
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - BroadcastService - msal:handleRedirectEnd results in setting inProgress from handleRedirect 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : @azure/[email protected] : Verbose - acquireTokenSilent called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : @azure/[email protected] : Verbose - acquireTokenSilent called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : @azure/[email protected] : Verbose - acquireTokenSilent called
bootstrap.bundle.min.js:20570 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.
bootstrap.bundle.min.js:20570
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - error acquiring token silently, acquiring by redirect
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : @azure/[email protected] : Verbose - acquireTokenRedirect called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:acquireTokenStart
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - BroadcastService - msal:acquireTokenStart results in setting inProgress from none to 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - getRedirectUri called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Authentication Scheme wasn't explicitly set in request, 
bootstrap.bundle.min.js:20570 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.
bootstrap.bundle.min.js:20570
bootstrap.bundle.min.js:20570 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.
bootstrap.bundle.min.js:20570
bootstrap.bundle.min.js:18795 handleRedirectObservable
bootstrap.bundle.min.js:18796 {authority: 'https://B2C.b2clogin.com/B2C…osoft.com/b2c_1a_signup_signin_passwordless_only/', uniqueId: 'guid', 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Guard - at least 1 account exists, can activate or load
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - initializeServerTelemetryManager called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - MSAL Interceptor activated
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - getting scopes for endpoint
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - no active account, fallback to first account
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - Interceptor - 1 scopes found for endpoint
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : @azure/[email protected] : Verbose - acquireTokenSilent called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : @azure/[email protected] : Verbose - acquireTokenSilent called for the first time, storing 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:acquireTokenStart
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Authentication Scheme wasn't explicitly set in request, defaulting to "Bearer" request
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - acquireTokenSilent - attempting to acquire token from web flow
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - initializeServerTelemetryManager called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Attempting to get cloud discovery metadata  from authority 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - The host is included in knownAuthorities. Creating new cloud 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Found cloud discovery metadata in authority configuration
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Attempting to get endpoint metadata from authority 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Did not find endpoint metadata in the config... Attempting 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Did not find endpoint metadata in hardcoded values... 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Found endpoint metadata in the cache.
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [GUID] : [email protected] : Verbose - Silent auth client created
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getAccessToken - Returning access token
bootstrap.bundle.min.js:20573 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:22 GMT] : [] : @azure/[email protected] : Verbose - Emitting event to callback GUID: msal:acquireTokenSuccess
bootstrap.bundle.min.js:18800 msalBroadcastService 1
bootstrap.bundle.min.js:18801 {eventType: 'msal:acquireTokenSuccess', interactionType: 'silent', payload: {…}, error: null, timestamp: 1731528262871}
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [] : @azure/[email protected] : Verbose - Interceptor - setting authorization headers
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - Attempting to get cloud discovery metadata  from authority 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - The host is included in knownAuthorities. Creating new cloud 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - Found cloud discovery metadata in authority configuration
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - Attempting to get endpoint metadata from authority 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - Did not find endpoint metadata in the config... Attempting 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - Did not find endpoint metadata in hardcoded values... 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - Found endpoint metadata in the cache.
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:23 GMT] : [GUID] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest called
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:24 GMT] : [GUID] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest: redirectStartPage set, 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:24 GMT] : [GUID] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest: Invoking 
bootstrap.bundle.min.js:20576 [Wed, 13 Nov 2024 20:04:24 GMT] : [GUID] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest: onRedirectNavigate did 

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

return new PublicClientApplication({
      auth: {
        clientId: environment.msalConfig.auth.clientId,
        authority: environment.msalConfig.auth.authority,
        knownAuthorities: [environment.msalConfig.auth.authorityDomain],
        redirectUri: '/',
        postLogoutRedirectUri: '/',
      },
      cache: {
        cacheLocation: BrowserCacheLocation.LocalStorage,
        storeAuthStateInCookie: this.isIE, // set to true for IE 11
      },
      system: {
        loggerOptions: {
          logLevel: LogLevel.Verbose,
          loggerCallback: (level, message, containsPii) => {
            if (containsPii) {
              return;
            }
            switch (level) {
              case LogLevel.Error:
                console.error(message);
                return;
              case LogLevel.Info:
                console.info(message);
                return;
              case LogLevel.Verbose:
                console.debug(message);
                return;
              case LogLevel.Warning:
                console.warn(message);
                return;
            }
          },
          piiLoggingEnabled: false
        },
      },
    });

Relevant Code Snippets

() {
    this.msalAuthService.handleRedirectObservable().subscribe();

    this.msalBroadcastService.msalSubject$
      .pipe(
        filter(
          (msg: EventMessage) =>
            msg.eventType === EventType.LOGIN_SUCCESS ||
            msg.eventType === EventType.ACQUIRE_TOKEN_SUCCESS
        ),
        takeUntil(this._destroying$)
      )
      .subscribe(result => {});

    this.msalBroadcastService.msalSubject$
      .pipe(
        filter(
          (msg: EventMessage) =>
            msg.eventType === EventType.LOGIN_FAILURE ||
            msg.eventType === EventType.ACQUIRE_TOKEN_FAILURE
        ),
        takeUntil(this._destroying$)
      )
      .subscribe((result: EventMessage) => {
        if (result.error instanceof AuthError) {
          this.handleFailure(result);
        }
      });
  } 
signIn() {
    const redirectFlowRequest = {
      scopes: ['openid'],
      authority: localStorage.getItem('msal.idtoken'),
    };
    this.redirectRequest(redirectFlowRequest);
  }

  redirectRequest(redirectFlowRequest: RedirectRequest) {
    if (this.msalGuardConfig.authRequest) {
      this.msalAuthService.loginRedirect({
        ...this.msalGuardConfig.authRequest,
        ...redirectFlowRequest,
      } as RedirectRequest);
    } else {
      this.msalAuthService.loginRedirect(redirectFlowRequest);
    }
  }
MSALInterceptorConfigFactory(): MsalInterceptorConfiguration {
    const protectedResources = Object.keys(environment.resources);
    debugger;
    const protectedResourceMap = new Map<string, Array<string>>();
    protectedResources.forEach(resource =>
      protectedResourceMap.set(
        environment.resources[resource].uri,
        environment.resources[resource].scope
      )
    );

    return {
      interactionType: InteractionType.Redirect,
      protectedResourceMap,
    };
  }
MSALGuardConfigFactory(): MsalGuardConfiguration {
    debugger;
    return { interactionType: InteractionType.Redirect };
  }

Reproduction Steps

  1. Go to app and get redirected to login page
  2. Enter creds
  3. Gets redirected to redirectUri and redirected back to login page

Expected Behavior

After 1st successful login, user should not have to login for the second time

Identity Provider

Azure B2C Custom Policy

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge

Regression

No response

@jackskelly-ctrl jackskelly-ctrl added bug-unconfirmed A reported bug that needs to be investigated and confirmed question Customer is asking for a clarification, use case or information. labels Nov 13, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Nov 13, 2024
@github-actions github-actions bot added b2c Related to Azure B2C library-specific issues msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications labels Nov 13, 2024
@tnorling
Copy link
Collaborator

You have a race. Your app is attempting to make API calls (invoking the interceptor) before the Guard has determined whether or not the user is actually signed in and before it completes the first interactive token acquisition. You need to wait until the inProgress observable is None before making any API calls. See here for more information about the redirect flow

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Nov 14, 2024
Copy link
Contributor

@jackskelly-ctrl This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.

@microsoft-github-policy-service microsoft-github-policy-service bot added the no-issue-activity Issue author has not responded in 5 days label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b2c Related to Azure B2C library-specific issues bug-unconfirmed A reported bug that needs to be investigated and confirmed msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Author Feedback Awaiting response from issue author no-issue-activity Issue author has not responded in 5 days public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

2 participants