msal.js loginRedirect() repeatedly redirecting to sign in window react.js msal.js loginRedirect() repeatedly redirecting to sign in window react.js azure azure

msal.js loginRedirect() repeatedly redirecting to sign in window react.js


You can also use an SPFx extension present on every page so the login popup is now able to close. The Redirect URL (SPFx/AAD) must have the root site collection specified.

Also, I have heard that this is an issue with certain versions of msal. You can try downgrading to msal 0.1.3 to solve this issue.


According to this github issue including the MSAL UserAgentApplication object on the page the application gets redirected to.

// This is weird but Microsoft login redirects back to the site and expects it to create the object before it closes the popup.// See https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/174if (location.hash.includes("id_token")) {  new UserAgentApplication("4ecf3d26-e844-4855-9158-b8f6c0121b50", null, null);}

One commenter states that he places this code in his componentWillMount method. The snippet above was posted verbatim from github, but I believe the correct call to the includes method would be on window.location.hash. I tried and couldn't get it working, but others said this worked for them.

Please update your post if you get it working. I've been on this almost all day and haven't figured out why the window won't disappear. I'm building an SPA, so theoretically, the UserAgentApplication object is on every "page".