title: BrowserAuthError: interaction_in_progress - Unable to fix, regardles of solutions found
body: <p>I'm implementing security for the applications at the company I'm working at right now. I'm using <code>@azure/msal-angular@2.0.2</code>, <code>@azure/msal-browser@2.16.1</code>. I followed the example found <a href="https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/v2-docs/initialization.md" rel="nofollow noreferrer">here</a>
  and got it working for the first application. I went on to implement it for the next application, which is basically the same one, just talks to a different api, but the complexity is the same. After possibly doing something wrong I keep getting the error:</p>
  <pre><code>core.js:6157 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.
  </code></pre>
  <p>I found several other posts that said to clear the caches, storages etc... But none of it works. All it does is prompt me to log in again, only to fill in the sessionStorage back with the same entries, amongst them the entry that says <code>msal.442edcf7-9e0c-469b-93fb-daa1839724bd.interaction.status</code> <code>interaction_in_progress</code>. As far as I know I've tried everthing I've found. Also the <a href="https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/v2-docs/errors.md#interaction_in_progress" rel="nofollow noreferrer">solution</a> from AzureAD themselves doesn't work.</p>
  <p>I'm very new to this so I might have missed something simple, if so, my apologies.</p>
  <p>My code can be found below.</p>
  <p><strong>Angular version</strong></p>
  <p><code>11.0.2</code></p>
  <p><strong>app.module.ts</strong></p>
  <pre><code>import {
    MsalBroadcastService,
    MsalGuard,
    MsalInterceptor,
    MsalModule, MsalRedirectComponent,
    MsalService
  } from &quot;@azure/msal-angular&quot;;
  import {BrowserCacheLocation, InteractionType, LogLevel, PublicClientApplication} from '@azure/msal-browser';
  
  
  const isIE = window.navigator.userAgent.indexOf('MSIE ') &gt; -1 || window.navigator.userAgent.indexOf('Trident/') &gt; -1;
  @NgModule({
    declarations: [
      AppComponent,
      HeaderComponent,
      RibonComponent
    ],
    imports: [
      BrowserModule,
      AppRoutingModule,
      ...,
      MsalModule.forRoot(
        new PublicClientApplication({ // MSAL Configuration
          auth: {
            clientId: &quot;442edcf7-...&quot;,
            authority: &quot;https://login.microsoftonline.com/81fa766e-...&quot;,
            redirectUri: window.location.origin,
          },
          cache: {
            cacheLocation : BrowserCacheLocation.LocalStorage,
            storeAuthStateInCookie: false, // set to true for IE 11
          },
          system: {
            loggerOptions: {
              loggerCallback: (level: LogLevel, message: string, containsPii: boolean): void =&gt; {
                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
            }
          }
        }), {
          interactionType: InteractionType.Popup, // MSAL Guard Configuration
        }, {
          protectedResourceMap: new Map([
            [ 'http://localhost:8400/', ['api://442edcf7-9e0c-469b-93fb-daa1839724bd/acces_as_user/Acces-user']],
            [ 'https://quality-score-dev-pcq-dev.bravo-apps.volvocars.biz/', ['api://442edcf7-9e0c-469b-93fb-daa1839724bd/acces_as_user/Acces-user']]
          ]),
          interactionType: InteractionType.Redirect // MSAL Interceptor Configuration
        }
      )
    ],
    providers: [
      EnvServiceProvider,
      {
        provide: MatPaginatorIntl,
        useClass: MatPaginatorIntlTranslator
      },
      {
        provide: HTTP_INTERCEPTORS,
        useClass: MsalInterceptor,
        multi: true
      },
      MsalService,
      MsalGuard,
      MsalBroadcastService,
    ],
    bootstrap: [AppComponent]
  })
  export class AppModule { }
  </code></pre>
  <p><em><strong>app.component.ts</strong></em></p>
  <pre><code>
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
  })
  export class AppComponent implements OnInit, OnDestroy{
    title = 'Quality score';
  
    isIframe = false;
    loginDisplay = false;
  
    activeUser = '';
  
    private readonly onDestroy$ = new Subject&lt;void&gt;()
  
    constructor(
      @Inject(MSAL_GUARD_CONFIG) private msalGuardConfig: MsalGuardConfiguration,
      private languageService: LanguageService,
      private authService: MsalService,
      private msalBroadcastService: MsalBroadcastService,
      private location: Location,
      private userService: UserService
    ){}
  
    ngOnInit(): void {
      const currentPath = this.location.path();
      // Dont perform nav if in iframe or popup, other than for front-channel logout
      this.isIframe = BrowserUtils.isInIframe() &amp;&amp; !window.opener &amp;&amp; currentPath.indexOf(&quot;logout&quot;) &lt; 0; // Remove this line to use Angular Universal
  
      this.msalBroadcastService.inProgress$
        .pipe(
          filter((status: InteractionStatus) =&gt; status === InteractionStatus.None),
          takeUntil(this.onDestroy$)
        )
        .subscribe(() =&gt; {
          this.setLoginDisplay();
          this.checkAndSetActiveAccount();
        })
    }
  
    ngOnDestroy() {
      this.onDestroy$.next();
    }
  
    setLoginDisplay() {
      this.loginDisplay = this.authService.instance.getAllAccounts().length &gt; 0;
    }
    checkAndSetActiveAccount(){
      /**
       * If no active account set but there are accounts signed in, sets first account to active account
       * To use active account set here, subscribe to inProgress$ first in your component
       * Note: Basic usage demonstrated. Your app may require more complicated account selection logic
       */
      let activeAccount = this.authService.instance.getActiveAccount();
  
      if (!activeAccount &amp;&amp; this.authService.instance.getAllAccounts().length &gt; 0) {
        let accounts = this.authService.instance.getAllAccounts();
        this.authService.instance.setActiveAccount(accounts[0]);
      }
  
      if(activeAccount) {
        this.userService.activeUserName = activeAccount.name;
        this.activeUser = activeAccount.name;
      }
    }
  
    logout(): void{
      this.authService.logoutRedirect();
    }
  }
  </code></pre>
  <p>I'm really lost and have no idea what I have done wrong. From my understanding there is a login process that was interupted, probably by me leaving the login screen, but now I have no idea how to &quot;finish it up&quot; or complete the process.</p>
  <p><em><strong>Update</strong></em></p>
  <p>I tried copying the LocalStorage values from the working application and I got it to work. Refreshing works and no errors appear, but when I logout and after it prompted me to login again and I do, then it's right back to the start again.</p>
  <p><em><strong>Solution update</strong></em></p>
  <p>I've had a breakthrough. If I change the login type to Popup and handle it this way, it's fixed. I can login and logout without any issues. However if I then change it back to Redirect, it's broken again. So for now I'll keep it on Popup. Simple solution, but I hadn't thought of it because I assumed the issue would be occur there as well.</p>