title: Login with AAD MSAL - Login is already in progress
body: <p>I have a ASP.net website, that uses MSAL to login.</p>
  
  <p>The issue I keep having is that, whenever the user logs in, then logs out again the user is redirected to a logout page.
  This page implements the <code>new Msal.UserAgentApplication(msalConfig).logout()</code> function, and redirects the user back to the login page.</p>
  
  <p>This all works perfectly. The login page will then automatically redirect the user back to the AAD login page.</p>
  
  <p>If the user then decides to login again, the result of <code>MyMsalObject.GetAccount()</code> returns null, and an error occurs that mentions the following:</p>
  
  <blockquote>
    <p>ClientAuthError: Login_In_Progress: Error during login call - login is already in progress.</p>
  </blockquote>
  
  <p>At first I used one js file to handle log in &amp; logout, I then realised that that probably wasn't he best solution, as it attempted a login on load.</p>
  
  <p>So I decided to split them up into two separate JS files but this hasn't fixed my problem.</p>
  
  <p>msalObject definition:</p>
  
  <pre><code>var msalConfig = {
      auth: {
          clientId: "my_client_id",
          authority: "my_authority_url",
          redirectUri: "http://localhost:port"
      },
      cache: {
          cacheLocation: "localStorage",
          storeAuthStateInCookie: true
      }
  };
  
  var myMSALObj = new Msal.UserAgentApplication(msalConfig);
  </code></pre>
  
  <p>login code:</p>
  
  <pre><code>$(document).ready(function(){
      if (!myMSALObj.getAccount()) {
              myMSALObj.loginRedirect(msalConfig);
              acquireTokenRedirectAndCallMSGraph();
      }
  });
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Some extra details.
  I've now made it so that users must click on a button before being redirected to Microsoft to login.</p>
  
  <p>The above unfortunately still applies. After logging in succesfully for the first time &amp; logging out, a secondary login attempt will not yield a value in the function <code>getaccount()</code> even though, it works perfectly the first time.</p>
  
  <p>The error I get after I've logged in is still the same namely:</p>
  
  <p><code>ClientAuthError: Login_In_Progress: Error during login call - login is already in progress.</code></p>
  
  <p>Even though I just logged in..</p>
  
  <p>Does anyone have a solution?</p>
  
  <p>Edit 2:</p>
  
  <p>There is a little bit of progress.. sort of, I've been able to fix the error above by changing way I log the user out.</p>
  
  <p>The config file is now a definition within document ready &amp; I've moved the log out function in there aswell.</p>
  
  <p>Although I now face a new challenge..</p>
  
  <pre><code>Refused to display 'https://login.microsoftonline.com/{{}}' in a frame because it set 'X-Frame-Options' to 'deny'.
  </code></pre>
  
  <p>And im not entirely sure if this is a step forward or backwards. The reproduction scenario remains the same, you log in, then you log out &amp; back in again, when microsoft sends the user back to the login page I get the error mentioned in this edit, but I don't get this error on the 1st login attempt.</p>
  
  <p>The answer stated on: <a href="https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/FAQs#q6-how-to-avoid-page-reloads-when-acquiring-and-renewing-tokens-silently" rel="noreferrer">https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/FAQs#q6-how-to-avoid-page-reloads-when-acquiring-and-renewing-tokens-silently</a> doesn't help at ALL, I'm using chrome but it still doesn't work..</p>