question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After trying to log in, login pop-up not closing and inside that pop-up window application is rendering

See original GitHub issue

Core Library

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

Core Library Version

2.32.0

Wrapper Library

MSAL React (@azure/msal-react)

Wrapper Library Version

1.4.6

Public or Confidential Client?

Public

Description

The issue is intermittent. In login pop-up window the user typed valid credentials to log in his Microsoft account. In most cases the user will successfully be logged in and pop-up will close.

However, sometimes login pop-up doesn’t close and inside that pop-up window the user can use the same application. I noticed that app is also running in the parent app window but user is not logged in.

I have noticed that logging out from your MS account in the browser, makes the popup require the email again and it works. IF there isn’t a fix for this, is there a way I can always ask for the credentials even though I am signed in in the browser?

When this happens, the URL contains a hash #code=0.AXQABc3mS.

Error Message

No response

Msal Logs

No response

MSAL Configuration

export const msalConfig: Configuration = {
  auth: {
    clientId: process.env.REACT_APP_AZURE_CLIENT_ID,
    redirectUri: process.env.REACT_APP_AZURE_REDIRECT_URI,
    postLogoutRedirectUri: process.env.REACT_APP_AZURE_POSTLOGOUT_REDIRECT_URI,
  },
  cache: {
    cacheLocation: "localStorage",
    storeAuthStateInCookie: isIE || isEdge || isFirefox,
  },
  system: {
    asyncPopups: true,
    allowRedirectInIframe: true, // Needed for Front-channel logout
    loggerOptions: {
      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;
          default:
            return;
        }
      },
    },
  },
};

Relevant Code Snippets

<MsalAuthenticationTemplate
        interactionType={InteractionType.Popup}
        authenticationRequest={authRequest}
        errorComponent={ErrorComponent}
        loadingComponent={LoadingComponent}
 />

Reproduction Steps

User clicks to log into application with his Microsoft account. Pop-up window shows up and user enters valid credentials to sign in with his MS account. The pop-up does not close and inside that pop-up window application is rendering.

Expected Behavior

After giving valid credentials the login pop-up window is always closing and user is logged into application.

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Chrome, Firefox

Regression

No response

Source

Internal (Microsoft)

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tnorlingcommented, Dec 15, 2022

Because this is a race condition. When it fails it means whatever is removing the hash won the race. When it succeeds it means MSAL.js won the race. By ensuring that your router is not acting upon the redirectUri page you eliminate the race and ensure that MSAL.js always has access to the hash.

0reactions
msftbot[bot]commented, Dec 26, 2022

@diamant-isufi-sveasolar 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intermittent: After trying to log in, login pop-up not closing and ...
The issue is intermittent. In login pop-up window the user typed valid credentials to log in his Microsoft account. In most cases the...
Read more >
My Windows Security SIgn in keeps popping up even after ...
I have an issue with my Windows Security Login popup. Whenever any application from Microsoft 365 tries to log in with my Microsoft...
Read more >
MSAL all tenants sign on with pop up redirects inside popup
The sign on works but the popup window itself shows the website instead of closing and my original web browser having the authentication....
Read more >
Troubleshooting PaperCut User Client Not Popping Up
Another trick is to check the Application Log, under Logs → Application Log. If you've printed a job, and the user has Account...
Read more >
Popups and window methods - The Modern JavaScript Tutorial
Most browsers block popups if they are called outside of user-triggered event handlers like onclick . For example: // popup blocked ...
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