MSAL Login loginPopup issue. BrowserAuthError: user_cancelled: User cancelled the flow. #7479
Labels
bug-unconfirmed
A reported bug that needs to be investigated and confirmed
msal-browser
Related to msal-browser package
msal-react
Related to @azure/msal-react
public-client
Issues regarding PublicClientApplications
question
Customer is asking for a clarification, use case or information.
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
3.28.0
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
2.2.0
Public or Confidential Client?
Public
Description
Hi,
I am encountering an issue with MSAL authentication in my production environment(or just using build from front end). When a user clicks the login button (which triggers await instance.loginPopup(loginRequest)), the following error appears in the console: BrowserAuthError: user_cancelled: User cancelled the flow and popup for login is displayed.
This problem does not occur during development. In my local setup, I run a Node.js backend on port 4151 and a frontend on port 3000. Under these conditions, the popup-based login works exactly as expected. However, after building the frontend and deploying it (serving the index.html from the production build), this issue arises.
When running in development mode with the following configuration:
the login popup does not function as expected.
Using loginRedirect working good, without any issue, in both cases development and build.
Error Message
BrowserAuthError: user_cancelled: User cancelled the flow.
MSAL Logs
MSAL: [Fri, 20 Dec 2024 06:17:30 GMT] : [] : @azure/[email protected] : Info - MsalProvider - msal:loginStart results in setting inProgress from none to login
MSAL: [Fri, 20 Dec 2024 06:17:30 GMT] : [0193e2b6-c89f-7271-97e5-059bfc9896e6] : [email protected] : Error - PopupHandler.monitorPopupForHash - window closed
Login error: BrowserAuthError: user_cancelled: User cancelled the flow.
at gN (BrowserAuthError.ts:366:12)
at PopupClient.ts:561:25
MSAL: [Fri, 20 Dec 2024 06:17:30 GMT] : [] : @azure/[email protected] : Info - MsalProvider - msal:loginFailure results in setting inProgress from login to none
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Expected Behavior
No error message appears immediately after clicking the login button.
The authentication process completes seamlessly within the popup.
Once authentication is successful, the popup closes automatically.
The main website then redirects the user to the home page without displaying duplicate login pages.
Identity Provider
Other
Browsers Affected (Select all that apply)
Chrome
Regression
No response
The text was updated successfully, but these errors were encountered: