microsoft-authentication-library-for-js: Updating to msal-browser 4.9.0 login doesn't work anymore
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
4.9.0
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
4.0.7
Public or Confidential Client?
Public
Description
(please go easy on me, this is my first time submitting a bug report)
Before updating my NPM packages I was able to have my angular application log a user in. After updating, the login processing doesn’t work anymore. If I revert my msal-angular and msal-browser packages back to 4.0.7 and 4.8.0, respectively, then the application logs in fine.
Error Message
No response
MSAL Logs
After updating my npm packages, the login process after a redirect seems to get stuck after the “initializeEnd”. It doesn’t seem to handle the redirect portion and finish logging the user in.
MsalBroadcastService inProgress$ startup MsalBroadcastService msalSubject$ msal:initializeStart {eventType: ‘msal:initializeStart’, interactionType: null, payload: null, error: null, timestamp: 1743002095450} [Wed, 26 Mar 2025 15:14:55 GMT] : [] : @azure/msal-common@15.4.0 : Info - CacheManager:getIdToken - Returning ID token [Wed, 26 Mar 2025 15:14:55 GMT] : [] : @azure/msal-common@15.4.0 : Info - CacheManager:getIdToken - Returning ID token Angular is running in development mode. [Wed, 26 Mar 2025 15:14:55 GMT] : [] : @azure/msal-common@15.4.0 : Info - CacheManager:getIdToken - Returning ID token MsalBroadcastService msalSubject$ msal:initializeEnd {eventType: ‘msal:initializeEnd’, interactionType: null, payload: null, error: null, timestamp: 1743002095482} [Wed, 26 Mar 2025 15:14:55 GMT] : [] : @azure/msal-browser@4.9.0 : Info - handleRedirectPromise called but there is no interaction in progress, returning null.
Network Trace (Preferrably Fiddler)
- Sent
- Pending
MSAL Configuration
export function loggerCallback(logLevel: LogLevel, message: string) {
console.log(message);
}
export function MSALInstanceFactory(): IPublicClientApplication {
return new PublicClientApplication({
auth: {
clientId: '<client-id>',
authority: "https://login.microsoftonline.com/<tenent-id>",
redirectUri: document.location.origin,
postLogoutRedirectUri: '/',
},
cache: {
cacheLocation: BrowserCacheLocation.SessionStorage,
},
system: {
allowPlatformBroker: false,
loggerOptions: {
loggerCallback,
logLevel: LogLevel.Info,
piiLoggingEnabled: true,
},
},
});
}
export function MSALInterceptorConfigFactory(): MsalInterceptorConfiguration {
const protectedResourceMap = new Map<string, Array<string>>();
protectedResourceMap.set('<url>', ['<scope>']);
return {
interactionType: InteractionType.Redirect,
protectedResourceMap,
};
}
export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes, withHashLocation()),
provideHttpClient(withInterceptorsFromDi(), withFetch()),
{
provide: HTTP_INTERCEPTORS,
useClass: MsalInterceptor,
multi: true,
},
{
provide: MSAL_INSTANCE,
useFactory: MSALInstanceFactory,
},
{
provide: MSAL_INTERCEPTOR_CONFIG,
useFactory: MSALInterceptorConfigFactory,
},
MsalService,
MsalGuard,
MsalBroadcastService
]
};
Relevant Code Snippets
async loginAzureAd() {
return new Promise<boolean>(async (resolve) => {
this.msalBroadcastService.msalSubject$.subscribe(event => {
console.log('MsalBroadcastService', 'msalSubject$', event.eventType, (event.error?.cause ?? '') + (event.error?.message ?? ''), event)
})
this.msalBroadcastService.inProgress$.subscribe(status => {
console.log('MsalBroadcastService', 'inProgress$', status)
if (status == InteractionStatus.None) {
let activeAccount = this.msalService.instance.getActiveAccount();
if (activeAccount) {
console.log('already an active account', activeAccount)
resolve(true)
} else {
let allAccounts = this.msalService.instance.getAllAccounts()
if (allAccounts.length == 0) {
console.log('no msal accounts')
this.msalService.instance.loginRedirect()
} else {
console.log('activating first account', allAccounts)
this.msalService.instance.setActiveAccount(allAccounts[0]);
resolve(true)
}
}
}
});
this.msalService.handleRedirectObservable().subscribe();
})
}
Reproduction Steps
- update npm packages so msal-angular is 4.0.8 and msal-browser is 4.9.0
- running the application the login process gets stuck after a redirect and never gets to an inProgress$ status of “none”
- revert npm packages to msal-angular is 4.0.7 and msal-browser is 4.8.0
- running the application the login process doesn’t get stick after redirect. The progress status gets “none”
Expected Behavior
The following log outputs are what login normally looks like after a redirect back to my page. You can see all the steps happen and the MsalBroadcastService.inProgress$ gets to a state of “none”, which I’m expecting.
MsalBroadcastService inProgress$ startup MsalBroadcastService msalSubject$ msal:initializeStart {eventType: ‘msal:initializeStart’, interactionType: null, payload: null, error: null, timestamp: 1742999991666} [Wed, 26 Mar 2025 14:39:51 GMT] : [] : @azure/msal-common@15.3.0 : Info - CacheManager:getIdToken - Returning ID token [Wed, 26 Mar 2025 14:39:51 GMT] : [] : @azure/msal-common@15.3.0 : Info - CacheManager:getIdToken - Returning ID token Angular is running in development mode. [Wed, 26 Mar 2025 14:39:51 GMT] : [] : @azure/msal-common@15.3.0 : Info - CacheManager:getIdToken - Returning ID token MsalBroadcastService msalSubject$ msal:initializeEnd {eventType: ‘msal:initializeEnd’, interactionType: null, payload: null, error: null, timestamp: 1742999991692} [Wed, 26 Mar 2025 14:39:51 GMT] : [] : @azure/msal-common@15.3.0 : Info - CacheManager:getIdToken - Returning ID token MsalBroadcastService msalSubject$ msal:handleRedirectStart {eventType: ‘msal:handleRedirectStart’, interactionType: ‘redirect’, payload: null, error: null, timestamp: 1742999991694} MsalBroadcastService inProgress$ handleRedirect [Wed, 26 Mar 2025 14:39:51 GMT] : [0195d2e5-358e-7f58-9785-bc2f05dd8d23] : msal.js.browser@4.8.0 : Info - handleRedirectPromise called but there is no interaction in progress, returning null. MsalBroadcastService msalSubject$ msal:handleRedirectEnd {eventType: ‘msal:handleRedirectEnd’, interactionType: ‘redirect’, payload: null, error: null, timestamp: 1742999991695} MsalBroadcastService inProgress$ none [Wed, 26 Mar 2025 14:39:51 GMT] : [] : @azure/msal-common@15.3.0 : Info - CacheManager:getIdToken - Returning ID token already an active account
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Chrome
Regression
@azure/msal-angular 4.0.7
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 19 (3 by maintainers)
I’m having the same problem, tried out v4.9.1 and the problem remained. Rolled back to @azure/msal-browser v4.8.0 and @azure/msal-angular v4.0.7 and logins worked as expected with redirect flow. With the new versions the InteractionStatus appears to get stuck in “startup” state.
@azure/msal-browser v4.9.1 was released yesterday. I tried that version, but it seems to have the same issue.
I am also unable to login after upgrading to 4.9.0. Same issue of handleRedirectPromise response being null. I am using just
@azure/msal-browserwith no wrapper lib. Downgrading to 4.8.0 fixes it.I’ve updated this morning and can confirm my Angular app is working as expected again, thank you!
Can folks try out the latest builds from today and let us know if this issue is fixed? Thank you!
Hey @StantonCoffey89 I am able to reproduce an issue with the interaction status not clearing out properly after user logs out (logoutRedirect) and then logs back in using the acquireTokenRedirect for msal-browser. Is this the same scenario you are facing or anyone else here is? If you can provide a full MSAL trace logs from the console, that would be helpful in confirming this use case.
We are working on reproducing on our end, we are not seeing it in our samples. If someone can share steps to repro this for msal-browser (msal-angular is shared in the issue desc), including msal configuration, is the migration done with reloading the page and the APIs used, it will be helpful to sort this early.
The deprecation announcement is made in response to the issues reported here to ensure other folks are not impacted.
We had to rollback to @azure/msal-browser v4.8.0. We are also using the redirect flow.
I’m having a slightly different issue, but potentially related. After logging out and redirecting, I get stuck in the
handleRedirectstate. After trying it with the samples and older versions, it appears that the problematic area was introduced in thehandleRedirectPromiseInternalfunction as part of Redirect flow temporary cache refactor (#7648).I had to roll back to:
4.9.0 redirect caching changes caused wiped out accounts on browser refresh. Doesn’t happen with 4.8.0.