MSAL Angular w/ B2C SPA client code flow w/ pkce
See original GitHub issueCore Library
MSAL.js v2 (@azure/msal-browser)
Core Library Version
2.21.0
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
2.1.0
Description
When the refresh token expires, with an angular spa configured for code flow pkce w/ b2c, the application goes into an infinite loop and becomes unresponsive after 24 hours when the refresh token expires
Error Message
Got 1000’s and 1000’s of these logs in console, to the point that the browser becomes unusable
Error: Uncaught (in promise): BrowserAuthError: interaction_in_progress: Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. For more visit: aka.ms/msaljs/browser-errors. t@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3869928 t@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3887338 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3889032 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:8135249 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:8152234 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3869378 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868420 A@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:104040 CC@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868179 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:8175348 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3869378 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868420 A@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:104040 CC@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868179 acquireTokenRedirect@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3971415 acquireTokenInteractively@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3979547 error@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3899629 onInvoke@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3568317 run@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:92043 @https://www.example.org/polyfills.1652abd69e0565092c78.js:1:102978 onInvokeTask@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3568210 runTask@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:92662 v@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:99244 promiseReactionJob@[native code] ua (main.bbbbe4bab3b701f34f01.js:1:3491864) handleError (main.bbbbe4bab3b701f34f01.js:1:3492035) next (main.bbbbe4bab3b701f34f01.js:1:3574419) (anonymous function) (main.bbbbe4bab3b701f34f01.js:1:3558595) __tryOrUnsub (main.bbbbe4bab3b701f34f01.js:1:3454720) next (main.bbbbe4bab3b701f34f01.js:1:3453973) _next (main.bbbbe4bab3b701f34f01.js:1:3453160) next (main.bbbbe4bab3b701f34f01.js:1:3452935) next (main.bbbbe4bab3b701f34f01.js:1:3457595) emit (main.bbbbe4bab3b701f34f01.js:1:3558466) run (polyfills.1652abd69e0565092c78.js:1:92044) onHandleError (main.bbbbe4bab3b701f34f01.js:1:3568589) runGuarded (polyfills.1652abd69e0565092c78.js:1:92224) (anonymous function) (polyfills.1652abd69e0565092c78.js:1:100874) v (polyfills.1652abd69e0565092c78.js:1:99312) promiseReactionJob
Msal Logs
Error: Uncaught (in promise): BrowserAuthError: interaction_in_progress: Interaction is currently in progress. Please ensure that this interaction has been completed before calling an interactive API. For more visit: aka.ms/msaljs/browser-errors. t@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3869928 t@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3887338 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3889032 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:8135249 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:8152234 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3869378 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868420 A@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:104040 CC@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868179 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:8175348 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3869378 @https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868420 A@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:104040 CC@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3868179 acquireTokenRedirect@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3971415 acquireTokenInteractively@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3979547 error@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3899629 onInvoke@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3568317 run@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:92043 @https://www.example.org/polyfills.1652abd69e0565092c78.js:1:102978 onInvokeTask@https://www.example.org/main.bbbbe4bab3b701f34f01.js:1:3568210 runTask@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:92662 v@https://www.example.org/polyfills.1652abd69e0565092c78.js:1:99244 promiseReactionJob@[native code] ua (main.bbbbe4bab3b701f34f01.js:1:3491864) handleError (main.bbbbe4bab3b701f34f01.js:1:3492035) next (main.bbbbe4bab3b701f34f01.js:1:3574419) (anonymous function) (main.bbbbe4bab3b701f34f01.js:1:3558595) __tryOrUnsub (main.bbbbe4bab3b701f34f01.js:1:3454720) next (main.bbbbe4bab3b701f34f01.js:1:3453973) _next (main.bbbbe4bab3b701f34f01.js:1:3453160) next (main.bbbbe4bab3b701f34f01.js:1:3452935) next (main.bbbbe4bab3b701f34f01.js:1:3457595) emit (main.bbbbe4bab3b701f34f01.js:1:3558466) run (polyfills.1652abd69e0565092c78.js:1:92044) onHandleError (main.bbbbe4bab3b701f34f01.js:1:3568589) runGuarded (polyfills.1652abd69e0565092c78.js:1:92224) (anonymous function) (polyfills.1652abd69e0565092c78.js:1:100874) v (polyfills.1652abd69e0565092c78.js:1:99312) promiseReactionJob
MSAL Configuration
{
auth: {
clientId: this.config.b2cConfiguration.b2cPolicies.clientId,
authority:
this.config.b2cConfiguration.b2cPolicies.authorities.signUpSignIn
.authority,
redirectUri: this.config.b2cConfiguration.b2cPolicies.redirectUri,
postLogoutRedirectUri:
this.config.b2cConfiguration.b2cPolicies.postLogoutRedirectUri,
knownAuthorities: [
this.config.b2cConfiguration.b2cPolicies.authorityDomain,
],
},
cache: {
cacheLocation: BrowserCacheLocation.LocalStorage,
storeAuthStateInCookie: this.isIE, // set to true for IE 11
},
}
Relevant Code Snippets
N/A, normal use of MSAL
Reproduction Steps
- Log into angular application
- Leave on for 24 hours (allowing silent refresh to occur).
- After 24 hours when the refresh token expires, B2C will throw a 400 error and MSAL goes into an infinite loop with the following error in the logs (after 15 minutes, I literally got 1000’s of pages of the same error in console)
Expected Behavior
After refresh token expires, it should redirect to B2C, get a fresh set of token/refresh token and start the cycle new
Identity Provider
Azure B2C Custom Policy
Browsers Affected (Select all that apply)
Safari
Regression
No response
Source
External (Customer)
Issue Analytics
- State:
- Created 2 years ago
- Comments:22 (16 by maintainers)
Top GitHub Comments
No updates yet, still getting an infinite loop when msal tries to do refresh token cycle w/ b2c
we’re adding some logic to clear the local/session storage after 12 hours so we don’t hit the 24 hour refresh token expiry time now to avoid the issue from happening, but it is just a bandaid fix so users aren’t stuck
we think the problem starts from this
https://{{B2C_TENANT}}.b2clogin.com/{{B2C_TENANT}}.onmicrosoft.com/b2c_1a_signuporsignin/v2.0/.well-known/openid-configuration due to access control checks.
we tried this on both a setup with frontdoor and without front door, and it gives the same issue, cause after this, it goes into its infinite loop
@johnyoungnvs This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.