loginRedirect() returns 302 Status and no redirection happens
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
2.35.0
Wrapper Library
Not Applicable
Wrapper Library Version
None
Public or Confidential Client?
Public
Description
Hello, I am developing Flutter Web App that utilises msal in authentication flow. I managed to implement the auth flow and it works fine in most cases but there are some issues with specific scenarios especially on Edge browser. When loginRedirect() is called on Edge and the user is logged in the browser then the user ends up in login loop. loginRedirect() calls https://login.microsoftonline.com/{tenantId} with all the necessary parameters but nothing happens. In network calls I can see that sometimes the request is all in red without any status or 302 status is returned with the location in header exactly the same as the one it was called with. As I mentioned before for other cases it works fine as well as on incognito mode on Edge Browser. Using promt=login does not change anything.
Error Message
No response
MSAL Logs
MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : @azure/[email protected] : Verbose - loginRedirect called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : @azure/[email protected] : Verbose - acquireTokenRedirect called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - preflightBrowserEnvironmentCheck started main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - preflightInteractiveRequest called, validating app environment main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.info] [Fri, 06 Dec 2024 12:38:52 GMT] : @azure/[email protected] : Info - Emitting event: msal:loginStart main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - initializeAuthorizationRequest called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - getRedirectUri called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Initializing BaseAuthRequest main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Authentication Scheme wasn't explicitly set in request, defaulting to "Bearer" request main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - initializeServerTelemetryManager called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - initializeAuthorizationRequest called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - getClientConfiguration called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - getDiscoveredAuthority called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Creating discovered authority with configured authority main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Attempting to get cloud discovery metadata in the config main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the cache. main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:52 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Did not find cloud discovery metadata in the cache... Attempting to get cloud discovery metadata from the network. main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Attempting to find a match between the developer's authority and the CloudInstanceDiscoveryMetadata returned from the network request. main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - cloud discovery metadata was successfully returned from getCloudDiscoveryMetadataFromNetwork() main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : @azure/[email protected] : Verbose - PerformanceClient: Emitting performance events main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Auth code client created main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : @azure/[email protected] : Verbose - createAuthCodeUrlQueryString: No account, adding login_hint from request main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest: redirectStartPage set, caching start page main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest: Invoking onRedirectNavigate callback main.dart.js:41789 https://login.microsoftonline.com/ main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:53 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - RedirectHandler.initiateAuthRequest: onRedirectNavigate did not return false, navigating is deprecated. Please include main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCrypto: modern crypto interface available main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCrypto: modern crypto interface available main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - handleRedirectPromise called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.info] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Info - Emitting event: msal:handleRedirectStart main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - handleRedirectPromise has been called for the first time, storing the promise main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - initializeServerTelemetryManager called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - getRedirectResponseHash called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Verbose - Hash does not contain known properties, returning cached hash main.dart.js:41789 MSAL: [LogLevel.info] [Fri, 06 Dec 2024 12:38:55 GMT] : [abcc3d0e-dbf0-48d2-acd6-b1b4e5e9301b] : [email protected] : Info - handleRedirectPromise did not detect a response hash as a result of a redirect. Cleaning temporary cache. main.dart.js:41789 MSAL: [LogLevel.info] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Info - Emitting event: msal:handleRedirectEnd main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCrypto: modern crypto interface available main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCrypto: modern crypto interface available main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:55 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:56 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:56 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:57 GMT] : @azure/[email protected] : Verbose - getAllAccounts called main.dart.js:41789 MSAL: [LogLevel.verbose] [Fri, 06 Dec 2024 12:38:57 GMT] : @azure/[email protected] : Verbose - BrowserCacheManager.getAccountKeys - No account keys found
Network Trace (Preferrably Fiddler)
- [ ] Sent
- [ ] Pending
MSAL Configuration
{
auth: {
clientId: myClientId,
authority: 'https://login.microsoftonline.com/{myTenantId}',
}
}
Relevant Code Snippets
RedirectRequest:
{
prompt: "login",
scope: ["user.read"],
redirectUri: window.location.href
}
Reproduction Steps
- Login to Edge web browser
- Trigger loginRedirect() function
- App reloads -> no redirect
Expected Behavior
Triggering loginRedirect() always show the Microsoft Login Page.
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Chrome, Edge
Regression
No response
Please help anyone. Spent hours and hours on this issue but no result
This is how my network calls look:
I've got the same problem in Chrome, but it depends on the user, or Chrome configuration because it works sometimes.
The issue was ultimately caused by the code invoking loginRedirect(). There was significant state refreshing happening on the frontend at the same time, which led to inconsistent behavior in some browsers. It's worth taking a closer look at that interaction.