microsoft-authentication-library-for-js: loginRedirect, loginPopup will stuck in callback page

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version


Wrapper Library

MSAL React (@azure/msal-react)

Wrapper Library Version


Public or Confidential Client?



When using loginPopup or loginRedirect, it will redirect to the redirectUri and eventually return to the original request location I’m not sure why I’m stuck on the redirectUri page and unable to log in successfully. The logs for both methods are shown below (I also log the path and hash)

loginRedirect: 截圖 2023-10-05 15 11 27

loginPopup 截圖 2023-10-05 15 14 18

Error Message

please see the above picture

Msal Logs

please see the above picture

MSAL Configuration

auth: {
    clientId: CLIENT_ID, // This is the ONLY mandatory field that you need to supply.
    authority: b2cPolicies.authorities.signUpSignInPwdLess.authority, // Use a sign-up/sign-in user-flow as a default authority
    knownAuthorities: [b2cPolicies.authorityDomain], // Mark your B2C tenant's domain as trusted.
    redirectUri: `https://${getEnvVar('HOST_NAME')}${Urls.account.AzureLoginCallback}`, // Points to window.location.origin. You must register this URI on Azure Portal/App Registration.
    navigateToLoginRequestUrl: true, // If "true", will navigate back to the original request location before processing the auth code response.
  cache: {
    cacheLocation: 'localStorage', // Configures cache location. "sessionStorage" is more secure, but "localStorage" gives you SSO between tabs.

Relevant Code Snippets

N/A If the information provided is not sufficient, please let me know

Reproduction Steps

N/A If the information provided is not sufficient, please let me know

Expected Behavior

After calling login method, MSAL should return to the original request location and set token

Identity Provider

Azure B2C Custom Policy

Browsers Affected (Select all that apply)

Chrome, Safari


No response


External (Customer)

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 16

Most upvoted comments

I’m encountering a similar problem where, after logging out and attempting to log back into the application, the redirection doesn’t take me to the intended page. Instead, it gets stuck with the callback URL information.


@devpolo Sorry for the late reply No, I don’t manage the return logic. The azure SDK will handle it automatically Or you can handle it manually, I remember there is an option you can config

@tnorling Thank you for your response. If my callback page is named callback.html, how can I determine whether the current request is a popup or a redirect? Does handleRedirectPromise handle this automatically? Thank you

const myMSALObj = new window.msal.PublicClientApplication(msalConfig);

  .then(() => myMSALObj.handleRedirectPromise())
  .then(response => {
    console.log('response', response);
  .catch(error => {

After testing, I found that logging in with a popup flow on a mobile device and redirecting to an HTML page using handleRedirectPromise leads to getting stuck on the callback page, and the hash disappears. Does this mean I need to create two separate redirect HTML files (one for redirect, one for popup)?