BrowserAuthError: interaction_in_progress: Interaction is currently in progress.

See original GitHub issue

Core Library

@azure/msal-browser

Core Library Version

2.14.0

Wrapper Library

@azure/msal-angular

Wrapper Library Version

2.0.0-beat-5

Description

While trying to do a query for https://graph.microsoft.com/v1.0/me on component init it throws “BrowserAuthError: interaction_in_progress: Interaction is currently in progress.” in redirect flow while pop-up flow works as expected without any problem.

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] (index.es.js:528) at new BrowserAuthError (index.es.js:7239) at Function.push.u8tD.BrowserAuthError.createInteractionInProgressError (index.es.js:7306) at PublicClientApplication.push.u8tD.ClientApplication.preflightInteractiveRequest (index.es.js:11077) at PublicClientApplication.<anonymous> (index.es.js:10316) at step (index.es.js:75) at Object.next (index.es.js:56) at index.es.js:49 at new ZoneAwarePromise (zone-evergreen.js:1387) at __awaiter (index.es.js:45) at resolvePromise (zone-evergreen.js:1213) at new ZoneAwarePromise (zone-evergreen.js:1390) at __awaiter (index.es.js:45) at PublicClientApplication.push.u8tD.ClientApplication.acquireTokenRedirect (index.es.js:10301) at MsalService.acquireTokenRedirect (azure-msal-angular.js:42) at MsalInterceptor.acquireTokenInteractively (azure-msal-angular.js:351) at CatchSubscriber.selector (azure-msal-angular.js:324) at CatchSubscriber.error (catchError.js:27) at subscribeToPromise.js:8 at ZoneDelegate.invoke (zone-evergreen.js:372)

Msal Logs

No response

MSAL Configuration

import { MsalGuardConfiguration, MsalInterceptorConfiguration } from "@azure/msal-angular";
import { IPublicClientApplication, PublicClientApplication, BrowserCacheLocation, LogLevel, InteractionType } from "@azure/msal-browser";


export class MSALConfiguration {
  // this is is only for IE11 support. In case we do not want to support IE we can remove this.
  static isIE = window.navigator.userAgent.indexOf("MSIE ") > -1 || window.navigator.userAgent.indexOf("Trident/") > -1;

  public static MSALInstanceFactory(): IPublicClientApplication {
    return new PublicClientApplication({
      auth: {
        clientId: 'c0509186-e1f9-4bd4-a07a-c1a7b98b26eb', // Test application id
        authority: 'https://login.microsoftonline.com/common',
        redirectUri: 'https://localhost:8080/user'
      },
      cache: {
        cacheLocation: BrowserCacheLocation.LocalStorage,
        storeAuthStateInCookie: this.isIE, // set to true for IE 11. Remove this line to use Angular Universal
      },
      system: {
        loggerOptions: {
          logLevel: LogLevel.Info,
          piiLoggingEnabled: false
        }
      }
    });
  }

  public static MSALInterceptorConfigFactory(): MsalInterceptorConfiguration {
    const protectedResourceMap = new Map<string, Array<string>>();
    protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read']);
    return {
      interactionType: InteractionType.Redirect,
      protectedResourceMap
    };
  }

  public static MSALGuardConfigFactory(): MsalGuardConfiguration {
    return {
      interactionType: InteractionType.Redirect,
      authRequest: {
        scopes: ['user.read']
      },
      loginFailedRoute: '/login-failed'
    };
  }
}

Relevant Code Snippets

"app.Module.ts"
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {
  MsalBroadcastService,
  MsalGuard,
  MsalInterceptor,
  MsalModule,
  MsalRedirectComponent,
  MsalService,
  MSAL_GUARD_CONFIG,
  MSAL_INSTANCE,
  MSAL_INTERCEPTOR_CONFIG
} from '@azure/msal-angular';

import { UserInformationComponent } from './user-information/user-information.component';
import { ActivateLicenceComponent } from './activate-licence/activate-licence.component';
import { InvalidLoginComponent } from './invalid-login/invalid-login.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { MSALConfiguration } from './Common/MSAL-Config';

@NgModule({
  declarations: [
    AppComponent,
    UserInformationComponent,
    ActivateLicenceComponent,
    InvalidLoginComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    MsalModule,
    HttpClientModule,
  ],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: MsalInterceptor,
      multi: true
    },
    {
      provide: MSAL_INSTANCE,
      useFactory: MSALConfiguration.MSALInstanceFactory
    },
    {
      provide: MSAL_GUARD_CONFIG,
      useFactory: MSALConfiguration.MSALGuardConfigFactory
    },
    {
      provide: MSAL_INTERCEPTOR_CONFIG,
      useFactory: MSALConfiguration.MSALInterceptorConfigFactory
    },
    MsalService,
    MsalGuard,
    MsalBroadcastService
  ],
  bootstrap: [AppComponent, MsalRedirectComponent]
})
export class AppModule { }

"user component"
import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import Swal from 'sweetalert2';

const GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.0/me'; //

class ProfileType {
  givenName?: string;
  surname?: string;
  mail?: string
  userPrincipalName?: string;
  id?: string;
}

@Component({
  selector: 'app-user-information',
  templateUrl: './user-information.component.html',
  styleUrls: ['./user-information.component.css']
})
export class UserInformationComponent implements OnInit {

  storeToken = '';

  constructor(private http: HttpClient, private route: ActivatedRoute) { }
  profile = new ProfileType();
  isRequestInProgress = false;
  ngOnInit(): void {
    this.route.queryParams
      .subscribe(params => {
        console.warn(params); // token param
        this.storeToken = params.token;
        // console.warn(this.storeToken); // sample token value
      }
      );
    this.getProfile();
  }

  getProfile() {
    this.http.get<ProfileType>(GRAPH_ENDPOINT)
      .subscribe(profile => {
        this.profile = profile;
      });
  }

  activateSubscription(): void {

    this.isRequestInProgress = true;
    const options = {
      headers: new HttpHeaders().append('Content-Type', 'application/json'),
    }

    this.http.post("https://localhost:44386/api/Fulfilment/activate", JSON.stringify(this.storeToken), options).subscribe(
      (data) => {
        this.isRequestInProgress = false;
        console.log(data);
        if (data) {
          Swal.fire({
            icon: 'info',
            title: 'Activated',
            position: 'center',
            heightAuto: false,
            text: 'You subscription has been activated. You can now close this window',
          })
        }
      },
      (err) => {
        this.isRequestInProgress = false;
        console.log(err);
        if (err instanceof HttpErrorResponse) {
          if (typeof err.error === 'string') {
            Swal.fire({
              icon: 'error',
              title: 'Not Activated',
              position: 'center',
              heightAuto: false,
              text: err.error
            })
          }
          else {
            Swal.fire({
              icon: 'error',
              title: 'Not Activated',
              position: 'center',
              heightAuto: false,
              text: 'Unable to activate subscription.'
            });
          }
        }
      }
    )
  }
}

Reproduction Steps

  1. Configure the app with the use of the setting provided in code snippet

Expected Behavior

BrowserAuthError: interaction_in_progress: Interaction is currently in progress. should be thrown and interceptor should handle it

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Chrome, Edge

Regression

No response

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
chanakya-netcommented, May 4, 2021

as I had said in my pervious comment

I don’t think so unless i did something silly and unable to catch it.

this was the case. My apologies for the wasting your time. I will close this. Thanks a lot for your help and time on this.

0reactions
chanakya-netcommented, May 4, 2021

@chanakya-1984 Are you able to provide verbose logs?

@jo-arroyo Below is the log events from MSAL logs. This also has been created using the same Stackblitz

full-log-msal.log

VM13:205 [Tue, 04 May 2021 04:47:05 GMT] :  : @azure/msal-browser@2.14.1 : Info - Emitting event: msal:handleRedirectStart
VM13:205 [Tue, 04 May 2021 04:47:05 GMT] :  : @azure/msal-browser@2.14.1 : Info - handleRedirectPromise called but there is no interaction in progress, returning null.
VM13:205 [Tue, 04 May 2021 04:47:05 GMT] :  : @azure/msal-browser@2.14.1 : Info - Emitting event: msal:handleRedirectEnd
VM13:205 [Tue, 04 May 2021 04:47:05 GMT] :  : @azure/msal-angular@2.0.0-beta.5 : Info - Interceptor - 1 scopes found for endpoint
VM13:205 [Tue, 04 May 2021 04:47:05 GMT] :  : @azure/msal-angular@2.0.0-beta.5 : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.
VM13:205 [Tue, 04 May 2021 04:47:05 GMT] :  : @azure/msal-browser@2.14.1 : Info - Emitting event: msal:loginStart
client:52 [WDS] Live Reloading enabled.
Navigated to https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=c0509186-e1f9-4bd4-a07a-c1a7b98b26eb&scope=user.read%20openid%20profile%20offline_access&redirect_uri=https%3A%2F%2Flocalhost%3A8080%2Fuser&client-request-id=de2f8e44-b325-4cad-8b48-7bedb99f5f57&response_mode=fragment&response_type=code&x-client-SKU=msal.js.browser&x-client-VER=2.14.1&x-client-OS=&x-client-CPU=&client_info=1&code_challenge=WKhTs1Xtm5pFt-n2jaei8b-xdI3VL0G1t5F8SJcUt1c&code_challenge_method=S256&nonce=9bd291cd-c16e-4fa6-9b39-2703d2244639&state=eyJpZCI6IjMwN2U0ZWYwLWY4MjMtNDFjMy1hNWRhLTkyMDM2ZDk2MjJkZiIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0%3D
overlay.js:2 BSSO Telemetry: {"result":"Error","error":"bssoNotSupported","type":"TBAuthTelemetry","data":{"BSSO.info":"not-supported"},"traces":["BrowserSSO Initialized","window.navigator.msLaunchUri is not available for _pullBrowserSsoCookie"]}
Navigated to https://login.microsoftonline.com/common/login
Navigated to https://localhost:8080/user
core.js:27950 Angular is running in development mode. Call enableProdMode() to enable production mode.
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:38 GMT] :  : @azure/msal-browser@2.14.1 : Info - Emitting event: msal:handleRedirectStart
core.js:27950 Angular is running in development mode. Call enableProdMode() to enable production mode.
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:38 GMT] :  : @azure/msal-angular@2.0.0-beta.5 : Info - Interceptor - 1 scopes found for endpoint
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:38 GMT] :  : @azure/msal-angular@2.0.0-beta.5 : Error - Interceptor - acquireTokenSilent rejected with error. Invoking interaction to resolve.
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:38 GMT] :  : @azure/msal-browser@2.14.1 : Info - Emitting event: msal:loginStart
core.js:6210 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] (index.es.js:528)
    at new BrowserAuthError (index.es.js:7239)
    at Function.push.u8tD.BrowserAuthError.createInteractionInProgressError (index.es.js:7306)
    at PublicClientApplication.push.u8tD.ClientApplication.preflightInteractiveRequest (index.es.js:11077)
    at PublicClientApplication.<anonymous> (index.es.js:10316)
    at step (index.es.js:75)
    at Object.next (index.es.js:56)
    at index.es.js:49
    at new ZoneAwarePromise (zone-evergreen.js:1387)
    at __awaiter (index.es.js:45)
    at resolvePromise (zone-evergreen.js:1213)
    at new ZoneAwarePromise (zone-evergreen.js:1390)
    at __awaiter (index.es.js:45)
    at PublicClientApplication.push.u8tD.ClientApplication.acquireTokenRedirect (index.es.js:10301)
    at MsalService.acquireTokenRedirect (azure-msal-angular.js:42)
    at MsalInterceptor.acquireTokenInteractively (azure-msal-angular.js:351)
    at CatchSubscriber.selector (azure-msal-angular.js:324)
    at CatchSubscriber.error (catchError.js:27)
    at subscribeToPromise.js:8
    at ZoneDelegate.invoke (zone-evergreen.js:372)
defaultErrorLogger @ core.js:6210
handleError @ core.js:6258
next @ core.js:29160
__tryOrUnsub @ Subscriber.js:183
next @ Subscriber.js:122
_next @ Subscriber.js:72
next @ Subscriber.js:49
next @ Subject.js:39
emit @ core.js:25902
(anonymous) @ core.js:28579
invoke @ zone-evergreen.js:372
run @ zone-evergreen.js:134
runOutsideAngular @ core.js:28482
onHandleError @ core.js:28579
handleError @ zone-evergreen.js:376
runGuarded @ zone-evergreen.js:147
api.microtaskDrainDone @ zone-evergreen.js:1074
drainMicroTaskQueue @ zone-evergreen.js:589
Promise.then (async)
scheduleMicroTask @ zone-evergreen.js:565
scheduleTask @ zone-evergreen.js:396
scheduleTask @ zone-evergreen.js:221
scheduleMicroTask @ zone-evergreen.js:241
scheduleResolveOrReject @ zone-evergreen.js:1266
then @ zone-evergreen.js:1410
bootstrapModule @ core.js:29202
zUnb @ main.ts:11
__webpack_require__ @ bootstrap:79
0 @ main.js:11
__webpack_require__ @ bootstrap:79
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:38 GMT] :  : @azure/msal-common@4.2.1 : Info - in acquireToken call
client:52 [WDS] Live Reloading enabled.
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:39 GMT] :  : @azure/msal-browser@2.14.1 : Info - BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: eyJpZCI6IjMwN2U0ZWYwLWY4MjMtNDFjMy1hNWRhLTkyMDM2ZDk2MjJkZiIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0=
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:39 GMT] :  : @azure/msal-browser@2.14.1 : Info - Emitting event: msal:loginSuccess
MSAL-Config.ts:6 [Tue, 04 May 2021 04:47:39 GMT] :  : @azure/msal-browser@2.14.1 : Info - Emitting event: msal:handleRedirectEnd

Read more comments on GitHub >

github_iconTop Results From Across the Web

BrowserAuthError: interaction_in_progress: Interaction is ...
I has this error when trying to loginRedirect in React app using @azure/msal-react@1.0.0-alpha.6 and @azure/msal-browser@2.11.2. The login data ...
Read more >
BrowserAuthError: interaction_in_progress - Unable to fix ...
BrowserAuthError : interaction_in_progress: Interaction is currently in progress. Please ensure that this interaction has been completed before ...
Read more >
interaction_in_progress" in SPA with MSAL redirect and iframe
BrowserAuthError : interaction_in_progress: Interaction is currently in progress. Please ensure that this interaction has been completed ...
Read more >
Interaction is currently in progress with azure/msal-browser ...
Coding example for the question BrowserAuthError: interaction_in_progress: Interaction is currently in progress with azure/msal-browser@2.11.2-Reactjs.
Read more >
BrowserAuthError | microsoft-authentication-libraries-for-js
Creates an error thrown when a browser interaction (redirect or popup) is in progress. Returns BrowserAuthError. Static createInvalidCacheTypeError.
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