AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.68k stars 2.65k forks source link

MSAL BrowserAuthError: interaction_in_progress with standard msalGuard and msalIntercept #4426

Closed PeterPrecision closed 2 years ago

PeterPrecision commented 2 years ago

Core Library

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

Core Library Version

^2.21.0

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

^2.1.0

Description

Hi, I have implemented MSAL for a standard angular 12 application. I am relying on the msalGuard for the authentication redirect. msalInterceptor has been configured to authenticate webapi calls. I am only using the msal components as documented but I am constantly seeing BrowserAuthError: interaction_in_progress. The primary issue is that the browser does not redirect to the uri the user was attempting to open. It flashes up but then it does a second redirect and finishes up on my callback uri with a token querystring.

Error Message

ERROR Error: Uncaught (in promise): 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. 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] (AuthError.js:27:1) at new BrowserAuthError (BrowserAuthError.js:169:1) at Function.push.48169.BrowserAuthError.createInteractionInProgressError (BrowserAuthError.js:236:1) at RedirectClient. (StandardInteractionClient.js:216:35) at step (_tslib.js:75:1) at Object.next (_tslib.js:56:46) at _tslib.js:49:1 at new ZoneAwarePromise (zone.js:1340:1) at __awaiter (_tslib.js:45:1) at RedirectClient.push.533.StandardInteractionClient.preflightInteractiveRequest (StandardInteractionClient.js:207:25) at resolvePromise (zone.js:1255:1) at zone.js:1162:1 at zone.js:1178:1 at ZoneDelegate.push.46026.ZoneDelegate.invoke (zone.js:400:1) at Object.onInvoke (core.js:28692:1) at ZoneDelegate.push.46026.ZoneDelegate.invoke (zone.js:399:1) at Zone.push.46026.Zone.run (zone.js:160:1) at zone.js:1318:1 at ZoneDelegate.push.46026.ZoneDelegate.invokeTask (zone.js:434:1) at Object.onInvokeTask (core.js:28679:1)

Msal Logs

[Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - MSAL Interceptor activated app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - getting scopes for endpoint app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - no active account, fallback to first account app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Info - Interceptor - 1 scopes found for endpoint app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Info - Interceptor - [85fa12b3-e245-4e97-a4bf-2b3d89343bec/webapi] scopes found for https://precisionformsdev.azurewebsites.net/api/companies app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - preflightBrowserEnvironmentCheck started app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - acquireTokenSilent called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve. app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - error acquiring token silently, acquiring by redirect app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - preflightBrowserEnvironmentCheck started app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - acquireTokenRedirect called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:loginStart app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [3e045dca-82e0-4341-bd2c-7ca4bfe3a936] : msal.js.browser@2.21.0 : Verbose - preflightInteractiveRequest called, validating app environment app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:loginFailure app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - Event callback registered with id: 2732621f-8596-40d5-b12b-6d9f1ede8d4c app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - MSAL Interceptor activated app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - getting scopes for endpoint app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - no active account, fallback to first account app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Info - Interceptor - 1 scopes found for endpoint app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Info - Interceptor - [user.read] scopes found for https://graph.microsoft.com/v1.0/me app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - preflightBrowserEnvironmentCheck started app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - acquireTokenSilent called auth-callback.component.ts:20 im here auth-callback.component! app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - MsalRedirectComponent activated app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - handleRedirectPromise called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:handleRedirectStart app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - Emitting event to callback 2732621f-8596-40d5-b12b-6d9f1ede8d4c: msal:handleRedirectStart app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - BroadcastService - msal:handleRedirectStart results in setting inProgress from startup to handleRedirect app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - handleRedirectPromise has been called for the first time, storing the promise app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - initializeServerTelemetryManager called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - getRedirectResponseHash called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - Hash does not contain known properties, returning cached hash app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - validateAndExtractStateFromHash called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - Returning state from hash app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - State extracted from hash app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - Current page is loginRequestUrl, handling hash app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - handleHash called, retrieved cached request app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - getClientConfiguration called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - getDiscoveredAuthority called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - Creating discovered authority with request authority app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve. app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - error acquiring token silently, acquiring by redirect app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - preflightBrowserEnvironmentCheck started app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - acquireTokenRedirect called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:loginStart app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - Emitting event to callback 2732621f-8596-40d5-b12b-6d9f1ede8d4c: msal:loginStart app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - BroadcastService - msal:loginStart results in setting inProgress from handleRedirect to login app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [60c35a4b-614a-41d7-8e59-235b484890c5] : msal.js.browser@2.21.0 : Verbose - preflightInteractiveRequest called, validating app environment app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:loginFailure app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - Emitting event to callback 2732621f-8596-40d5-b12b-6d9f1ede8d4c: msal:loginFailure app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-angular@2.1.0 : Verbose - BroadcastService - msal:loginFailure results in setting inProgress from login to none 2core.js:6498 ERROR Error: Uncaught (in promise): 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. 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] (AuthError.js:27:1) at new BrowserAuthError (BrowserAuthError.js:169:1) at Function.push.48169.BrowserAuthError.createInteractionInProgressError (BrowserAuthError.js:236:1) at RedirectClient. (StandardInteractionClient.js:216:35) at step (_tslib.js:75:1) at Object.next (_tslib.js:56:46) at _tslib.js:49:1 at new ZoneAwarePromise (zone.js:1340:1) at awaiter (_tslib.js:45:1) at RedirectClient.push.533.StandardInteractionClient.preflightInteractiveRequest (StandardInteractionClient.js:207:25) at resolvePromise (zone.js:1255:1) at zone.js:1162:1 at zone.js:1178:1 at ZoneDelegate.push.46026.ZoneDelegate.invoke (zone.js:400:1) at Object.onInvoke (core.js:28692:1) at ZoneDelegate.push.46026.ZoneDelegate.invoke (zone.js:399:1) at Zone.push.46026.Zone.run (zone.js:160:1) at zone.js:1318:1 at ZoneDelegate.push.46026.ZoneDelegate.invokeTask (zone.js:434:1) at Object.onInvokeTask (core.js:28679:1) defaultErrorLogger @ core.js:6498 handleError @ core.js:6546 next @ core.js:29303 __tryOrUnsub @ Subscriber.js:183 next @ Subscriber.js:122 _next @ Subscriber.js:72 next @ Subscriber.js:49 next @ Subject.js:39 emit @ core.js:25955 (anonymous) @ core.js:28718 push.46026.ZoneDelegate.invoke @ zone.js:400 push.46026.Zone.run @ zone.js:160 runOutsideAngular @ core.js:28591 onHandleError @ core.js:28718 push.46026.ZoneDelegate.handleError @ zone.js:404 push.46026.Zone.runGuarded @ zone.js:174 _loop_2 @ zone.js:1113 api.microtaskDrainDone @ zone.js:1125 drainMicroTaskQueue @ zone.js:627 Promise.then (async) scheduleMicroTask @ zone.js:603 push.46026.ZoneDelegate.scheduleTask @ zone.js:424 push.46026.Zone.scheduleTask @ zone.js:248 push.46026.Zone.scheduleMicroTask @ zone.js:268 scheduleResolveOrReject @ zone.js:1308 ZoneAwarePromise.then @ zone.js:1466 bootstrapModule @ core.js:29345 14431 @ main.ts:13 webpack_require @ bootstrap:19 webpack_exec @ sidenav-list.component.html:1 (anonymous) @ sidenav-list.component.html:1 webpack_require__.O @ chunk loaded:25 (anonymous) @ sidenav-list.component.html:1 webpackJsonpCallback @ jsonp chunk loading:72 (anonymous) @ main-es2018.5f0350fe239c6d197d74.js:1 app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - Auth code client created app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : msal.js.browser@2.21.0 : Verbose - RedirectHandler.handleCodeResponse called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : [981178ec-6c93-4e6a-a5b2-0584543b1893] : @azure/msal-common@6.0.0 : Info - in acquireToken call app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: eyJpZCI6IjE2OWQwZjEwLWE5NzItNDRmNC04YmFjLTlmNTEzNmRiNzA0MSIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0= app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:loginSuccess app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - Emitting event to callback 2732621f-8596-40d5-b12b-6d9f1ede8d4c: msal:loginSuccess app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - handleRedirectResponse returned result, login success app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:handleRedirectEnd app.module.ts:76 [Thu, 20 Jan 2022 07:18:34 GMT] : @azure/msal-browser@2.21.0 : Verbose - Emitting event to callback 2732621f-8596-40d5-b12b-6d9f1ede8d4c: msal:handleRedirectEnd app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - handleRedirectPromise called app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - handleRedirectPromise has been called previously, returning the result from the first call app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-angular@2.1.0 : Verbose - MSAL Interceptor activated app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - getting scopes for endpoint app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - no active account, fallback to first account app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - getAllAccounts called app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-angular@2.1.0 : Info - Interceptor - 1 scopes found for endpoint app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-angular@2.1.0 : Info - Interceptor - [85fa12b3-e245-4e97-a4bf-2b3d89343bec/webapi] scopes found for https://precisionformsdev.azurewebsites.net/api/companylocation app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - preflightBrowserEnvironmentCheck started app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - acquireTokenSilent called app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - acquireTokenSilent called for the first time, storing active request app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : [529af79b-b0c5-4ce0-9c0f-98cd8eb518f6] : msal.js.browser@2.21.0 : Verbose - Initializing BaseAuthRequest app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : [529af79b-b0c5-4ce0-9c0f-98cd8eb518f6] : msal.js.browser@2.21.0 : Verbose - Authentication Scheme wasn't explicitly set in request, defaulting to "Bearer" request app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:acquireTokenStart app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - Emitting event to callback 2732621f-8596-40d5-b12b-6d9f1ede8d4c: msal:acquireTokenStart app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : [529af79b-b0c5-4ce0-9c0f-98cd8eb518f6] : msal.js.browser@2.21.0 : Verbose - initializeServerTelemetryManager called app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : [529af79b-b0c5-4ce0-9c0f-98cd8eb518f6] : msal.js.browser@2.21.0 : Verbose - getClientConfiguration called app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : [529af79b-b0c5-4ce0-9c0f-98cd8eb518f6] : msal.js.browser@2.21.0 : Verbose - getDiscoveredAuthority called app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : [529af79b-b0c5-4ce0-9c0f-98cd8eb518f6] : msal.js.browser@2.21.0 : Verbose - Creating discovered authority with request authority app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : [529af79b-b0c5-4ce0-9c0f-98cd8eb518f6] : msal.js.browser@2.21.0 : Verbose - Silent auth client created app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Info - Emitting event: msal:acquireTokenSuccess app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-browser@2.21.0 : Verbose - Emitting event to callback 2732621f-8596-40d5-b12b-6d9f1ede8d4c: msal:acquireTokenSuccess app.module.ts:76 [Thu, 20 Jan 2022 07:18:35 GMT] : @azure/msal-angular@2.1.0 : Verbose - Interceptor - setting authorization headers

MSAL Configuration

MsalModule.forRoot( new PublicClientApplication({
      auth: {
        clientId: environment.config.clientId, // This is your client ID
        authority: 'https://login.microsoftonline.com/'+environment.config.tenant, //'Enter_the_Tenant_Info_Here', // This is your tenant ID
        redirectUri: environment.config.redirectUri,// This is your redirect URI

        },
      cache: {
        cacheLocation: 'localStorage',
        storeAuthStateInCookie: isIE,
      },
      system: {
        loggerOptions: {
          loggerCallback,
          logLevel: LogLevel.Verbose,
          piiLoggingEnabled: true
        }

    }

    }), {
      interactionType: InteractionType.Redirect,
      authRequest: {
        scopes: ['user.read','85fa12b3-e245-4e97-a4bf-2b3d89343bec/webapi']
        }
    }, {
      interactionType: InteractionType.Redirect, // MSAL Interceptor Configuration
      protectedResourceMap: new Map([ 
          ['https://graph.microsoft.com/v1.0/me', ['user.read']],
          [environment.apiUrl,['85fa12b3-e245-4e97-a4bf-2b3d89343bec/webapi']]
      ])
    })
  ],

Relevant Code Snippets

path: '',
    runGuardsAndResolvers: 'always',

    children: [
      { path: '', component: AuthCallbackComponent },
      { path: 'auth-callback', component: AuthCallbackComponent },
      { path: 'logout', component: LogoutComponent, },
      { path: 'welcome', component: WelcomeComponent,canActivate: [MsalGuard] },
      { path: 'maintenance', component: MaintenanceComponent,canActivate: [MsalGuard] },
...

//this is a reasonably sized web app but this is the first level which i think is relevant. it is //relying on the msalguard to trigger the redirect to authenticate.

Reproduction Steps

I cannot upload the entire application and I don't have time to build a sample. this is a real world problem. Steps to reproduce, try to open the app with a url that includes a path.

Expected Behavior

One authentication redirect which comes back to the original URL and not callback?token=AB#%

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Chrome, Internet Explorer

Regression

This is a new implementation.

Source

External (Customer)

PeterPrecision commented 2 years ago

If you need an account to access the application please let me know.

jasonnutter commented 2 years ago

@PeterPrecision It looks like there may be a race condition in your application. Is your application invoking the http call that triggers in the MSAL Interceptor immediately on page load?

PeterPrecision commented 2 years ago

Hi Jason,

Thanks for your email. Yes, I think I found it. The header component was firing off a request to the graph api to get the logged in user.

Your email has confirmed my suspicion.

I’ve moved it to the base component and wrapped it with the following which seems to have fixed the issue:

this.msalBroadcastService.inProgress$ .pipe( filter((status: InteractionStatus) => status === InteractionStatus.None), takeUntil(this._destroying$) ) .subscribe(() => { this.authService.getUser().subscribe((user) => {

    console.log(user);
    this.store.dispatch(
      new fromRootUserProfileActions.SetUserProfileEmail(
        user.userPrincipalName
      )
    );
    this.store.dispatch(new fromUserProfileActions.LoadUP());

  });
})

Thanks for your help!

Kind Regards, Pete Ribbons

[cid:PrecisionLogo_b6704c0c-fd38-4229-8e85-4bd7615faa78.png] PETER RIBBONS Senior Developer

    Precision Group of Companies Pty Ltd

Level 25, 9 Castlereagh Street, Sydney NSW 2000 T +61 2 9225 1400 | M +61 450 285 698 @.*** | www.precision.com.au

[cid:iconfinder_2018_social_media_popular_app_logo_linkedin_3225190_18fc55af-0016-4ede-8042-d78fc0cc8810.png]https://www.linkedin.com/company/precision-group-of-companies [cid:iconfinder_2018_social_media_popular_app_logo_facebook_3225194_a9cad634-b59c-4892-97c8-2ed9e7d170c8.png] https://www.facebook.com/precisiongroup/ [cid:iconfinder_2018_social_media_popular_app_logo_instagram_3225191(1)_8c121dc6-7881-4724-b257-5873d3f60e63.png] https://www.instagram.com/precisiongroup/ [cid:iconfinder_2018_social_media_popular_app_logo_twitter_3225183_ee9af695-3265-4015-9b45-98cfed737958.png] https://twitter.com/precisiongroup [cid:iconfinder_2018_social_media_popular_app_logo_youtube_3225180_55ffcb1d-17b3-42f0-ac87-32fc5236e7ee.png] https://www.youtube.com/channel/UCpGv0x2TttURISDvPbm6XWw/videos

This e-mail is confidential and may be legally privileged or contain copyright material. This e-mail and any attachments are solely for the use of the intended recipient. If you are not the intended recipient, be advised that you have received this message in error, and you must not use, read, distribute or copy it. Please contact the sender immediately by reply email, and delete both emails and any attachments. Any disclosure, copying, distribution, reliance or use of the contents or information received in error is strictly prohibited. Precision Group does not accept liability in connection with any computer virus, data corruption, delay, interruption, unauthorised access or unauthorised amendment. From: Jason Nutter @.> Sent: Tuesday, 25 January 2022 4:52 AM To: AzureAD/microsoft-authentication-library-for-js @.> Cc: Peter Ribbons @.>; Mention @.> Subject: Re: [AzureAD/microsoft-authentication-library-for-js] MSAL BrowserAuthError: interaction_in_progress with standard msalGuard and msalIntercept (Issue #4426)

@PeterPrecisionhttps://hes32-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fPeterPrecision&umid=da3df9a4-8955-4406-9c8b-256032bd5c10&auth=fa9bf0a8f7937dab7cee4ac04fe9e40ec39d44e5-5c728e1b9181c14d00890cb88368d31d6c5c5a20 It looks like there may be a race condition in your application. Is your application invoking the http call that triggers in the MSAL Interceptor immediately on page load?

— Reply to this email directly, view it on GitHubhttps://hes32-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fAzureAD%2fmicrosoft%2dauthentication%2dlibrary%2dfor%2djs%2fissues%2f4426%23issuecomment%2d1020375903&umid=da3df9a4-8955-4406-9c8b-256032bd5c10&auth=fa9bf0a8f7937dab7cee4ac04fe9e40ec39d44e5-b6fdacfc097676cad62edc70955ba4ba5207b4e0, or unsubscribehttps://hes32-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fnotifications%2funsubscribe%2dauth%2fAXMJKD4QT5Q7DLUD47JZXFLUXWGUHANCNFSM5ML63Y2Q&umid=da3df9a4-8955-4406-9c8b-256032bd5c10&auth=fa9bf0a8f7937dab7cee4ac04fe9e40ec39d44e5-d485a51b00b5c5a716b1622d23e6f29f51f05d43. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.**@.>>

jasonnutter commented 2 years ago

You're welcome! Closing.