AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.64k stars 2.65k forks source link

handleRedirectStart is not resolved #3324

Closed iamstiil closed 3 years ago

iamstiil commented 3 years ago

Library

Framework

Description

I'm having an issue that handleRedirect is started but not resolved.

Error Message

Here is the log I get when calling the page, and then logging in:

Navigated to http://localhost:4200/en
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectStart
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectStart
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectStart results in setting inProgress to handleRedirect
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectStart results in setting inProgress to handleRedirect
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-browser@2.13.0 : Info - handleRedirectPromise called but there is no interaction in progress, returning null.
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-browser@2.13.0 : Info - handleRedirectPromise called but there is no interaction in progress, returning null.
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectEnd
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectEnd
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectEnd results in setting inProgress to none
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:06 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectEnd results in setting inProgress to none
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:07 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - useMsalAuthentication - No user is authenticated, attempting to login
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:07 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - useMsalAuthentication - No user is authenticated, attempting to login
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:07 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:ssoSilentStart
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:07 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:ssoSilentStart
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:07 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:ssoSilentStart results in setting inProgress to ssoSilent
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:07 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:ssoSilentStart results in setting inProgress to ssoSilent
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-browser@2.13.0 : Info - BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: eyJpZCI6IjY3ODMwYzFiLWI3ZjEtNGRiOS1hM2RhLTc2ZGFiMjllOTBiYyIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoic2lsZW50In19
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-browser@2.13.0 : Info - BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: eyJpZCI6IjY3ODMwYzFiLWI3ZjEtNGRiOS1hM2RhLTc2ZGFiMjllOTBiYyIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoic2lsZW50In19
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:ssoSilentFailure
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:ssoSilentFailure
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:ssoSilentFailure results in setting inProgress to none
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:08 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:ssoSilentFailure results in setting inProgress to none
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:41 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:loginStart
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:41 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:loginStart
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:41 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:loginStart results in setting inProgress to login
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:41 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:loginStart results in setting inProgress to login
Navigated to https://***.b2clogin.com/***.onmicrosoft.com/b2c_1_signinpolicy/oauth2/v2.0/authorize?client_id=***&scope=openid%20offline_access%20***%20profile&redirect_uri=http%3A%2F%2Flocalhost%3A4200&client-request-id=***&response_mode=fragment&response_type=code&x-client-SKU=msal.js.browser&x-client-VER=2.13.0&x-client-OS=&x-client-CPU=&client_info=1&code_challenge=***&code_challenge_method=S256&sid=***&nonce=***&state=***%3D
Navigated to http://localhost:4200/en
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:49 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectStart
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:49 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectStart
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:49 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectStart results in setting inProgress to handleRedirect
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:49 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectStart results in setting inProgress to handleRedirect
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:50 GMT] :  : @azure/msal-common@4.1.0 : Info - in acquireToken call
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:50 GMT] :  : @azure/msal-common@4.1.0 : Info - in acquireToken call
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: eyJpZCI6ImNiNWY1NjQwLWRiYWMtNDFmYS04MjlkLWZiMGU5YmQyMjVlMyIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0=
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: eyJpZCI6ImNiNWY1NjQwLWRiYWMtNDFmYS04MjlkLWZiMGU5YmQyMjVlMyIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoicmVkaXJlY3QifX0=
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:loginSuccess
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:loginSuccess
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - updating account state
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - updating account state
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:loginSuccess results in setting inProgress to none
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:loginSuccess results in setting inProgress to none
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectEnd
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectEnd
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectEnd results in setting inProgress to none
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectEnd results in setting inProgress to none
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - no account changes
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectStart
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-browser@2.13.0 : Info - Emitting event: msal:handleRedirectStart
instance.ts?8155:19 [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectStart results in setting inProgress to handleRedirect
instance.ts?8155:30 [2] [Mon, 29 Mar 2021 07:43:51 GMT] :  : @azure/msal-react@1.0.0-beta.1 : Info - MsalProvider - msal:handleRedirectStart results in setting inProgress to handleRedirect

MSAL Configuration

{
  auth: {
    clientId: environment.clientId,
    authority: environment.tokenAuthority,
    knownAuthorities: environment.knownAuthorities,
    redirectUri: environment.redirectUri,
  },
  system: {
    loggerOptions: {
      loggerCallback: (level, msg) => {
        switch (level) {
          case LogLevel.Error:
            console.error(msg);
            break;
          case LogLevel.Warning:
            console.warn(msg);
            break;
          case LogLevel.Info:
            console.info(msg);
            break;
          case LogLevel.Verbose:
            console.trace(msg);
            break;
          default:
            break;
        }
      },
    },
  },
}

Reproduction steps

Expected behavior

Before or after I redirect to my authenticated area the InteractionStatus should be updated.

Identity Provider

Browsers/Environment

Regression

Security

Source

tnorling commented 3 years ago

@iamstiil Can you please share code snippets showing how you are using the libraries? I see many handleRedirect related logs, are you calling handleRedirectPromise manually? (you should not be)

iamstiil commented 3 years ago

Sorry, I have been rewriting a lot of stuff so i can't share any code. If you want to recreate the situation, here are some information regarding the project:

If you need anything more, just ping me :)

tnorling commented 3 years ago

@iamstiil One thing to double check; please make sure PublicClientApplication is not initialized inside of a React component to prevent it from reinitializing when components rerender.

I unfortunately cannot provide any additional insights without a minimal reproduction. If you can reproduce this with one of our samples or provide small snippets of your code I am happy to take a look.

tnorling commented 3 years ago

Closing due to inactivity. Please open a new issue if this has not been resolved. Thanks!