Closed vinothkummar closed 8 months ago
This might be happening because of 'authority mismatch error'. The account that you might be setting as the active account might be of different tenant than the tenant you're logging in. Please update the active account with the account which of the same tenant. To be specific, you need to update your checkAndSetActiveAccount() function in the app.component.ts
This is how I modified it in my usecase :
checkAndSetActiveAccount() {
let activeAccount: AccountInfo | null = this.authService.instance.getActiveAccount();
let accounts = this.authService.instance.getAllAccounts();
let tenantAccounts = accounts.filter(x => x.tenantId == environment.tenantId);
if (activeAccount && activeAccount.tenantId != environment.tenantId && tenantAccounts && tenantAccounts.length > 0) {
this.authService.instance.setActiveAccount(tenantAccounts[0]);
}
else if (!activeAccount && accounts.length > 0) {
this.authService.instance.setActiveAccount(tenantAccounts[0]);
}
else if (!activeAccount && accounts.length == 0) {
this.loginRedirect();
}
this.checkIfActiveAccountExists(); //Function just used for routing in case active account is set
}
I've been hitting this error a lot intermittently, it seems to go away eventually on it's own, or when user's purge their local storage, active account is of the same tenant.
These errors mean that sessionStorage has been cleared of temporary artifacts before MSAL has had a chance to retrieve them. If you're hitting this intermittently it likely means you have a race condition somewhere. You should debug and see if you can trace where the storage entries are cleared.
I'd also recommend upgrading to the latest version as we've had bugs related to temp storage in the past which have since been resolved.
Hi all, Thank you for your helping comments but still my issues are not resolved I'll be adding more details and some error logs .
Please leave my issue open now. thank you
At the same time if i look in to the network tab
https://emporosclientportalqat.b2clogin.com/emporosclientportalqat.onmicrosoft.com/b2c_1a_goldhawk/oauth2/v2.0/token this call returns 200 and the payload what is been passed eyJraWQiOiJYdmJ4dzQ0Z09Denh5amdtWFJRdjlFQS1jY1dYa29zWnFjZjhrN2xQdVRNIiwidmVyIjoiMS4wIiwiemlwIjoiRGVmbGF0ZSIsInNlciI6IjEuMCJ9.vTncpB93p2CfMiZ11OPerjWjKG5G6s18KlosRmROY7JRNClb7TyjpC7JNLl8yZJBZcJrUuvkqITi4xooSUJczPlHYhYRK-kpPQWs74AgCVp5SDEI5BoY5FA17NX0aDSgZdVtXgCRzbMVF93SQfCu0uRVY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
But it is keep repeating the loop cycle msalacquiretokensuccess
Using the following Azure dependecies in Nextjs:
"@azure/msal-browser": "^3.11.0", "@azure/msal-node": "^2.6.5", "@azure/msal-react": "^2.0.13",
` There is still the issue:
BrowserAuthError: no_token_request_cache_error: No token request found in cache. at c (701-09290108fa8b325.js:7:122739) at G.getCachedRequest (701-09290108fa8b325.js:5:25662) at handleResponse (701-09290108fa8b325.js:17:69220) at ev.handleRedirectPromise (701-09290108fa8b325.js:17:66959) at 701-09290108fa8b325.js:15:61188 at h3.handleRedirectPromise (701-09290108fa8b325.js:7:8796) at u.handleRedirectPromise (701-09290108fa8b325.js:1:54933) at 701-09290108fa8b325.js:17:208113 `
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
"@azure/msal-browser": "^2.22.1"
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
"@azure/msal-angular": "^2.1.2",
Public or Confidential Client?
Public
Description
After login with the credentials it is keep redirecting to the same page again in a loop and the policy behind custom policy in order for me to set up the office 365 identity provider sign up. => this is behaviour I see it in the edge browser.
If I run the application in the visual studio code debut mode and which open in the open chrome browser; it takes credentials and throws error BrowserAuthError: no_token_request_cache_error: No token request found in cache. at BrowserAuthError.AuthError [as constructor] (AuthError.js:27:24) at new BrowserAuthError (BrowserAuthError.js:197:28) at BrowserAuthError.createNoTokenRequestCacheError (BrowserAuthError.js:354:16) at BrowserCacheManager.getCachedRequest (BrowserCacheManager.js:802:19) at RedirectClient. (RedirectClient.js:222:61)
at step (_tslib.js:75:23)
at Object.next (_tslib.js:56:53)
at _tslib.js:49:71
at new ZoneAwarePromise (zone.js:1427:29)
at __awaiter (_tslib.js:45:12)
Error: Uncaught (in promise): ClientAuthError: state_not_found: State not found: Cached State ClientAuthError: state_not_found: State not found: Cached State at ClientAuthError.AuthError [as constructor] (AuthError.js:27:24) at new ClientAuthError (ClientAuthError.js:206:28) at ClientAuthError.createStateNotFoundError (ClientAuthError.js:282:16) at RedirectHandler. (RedirectHandler.js:96:35)
at step (_tslib.js:75:23)
at Object.next (_tslib.js:56:53)
at _tslib.js:49:71
at new ZoneAwarePromise (zone.js:1427:29)
at __awaiter (_tslib.js:45:12)
at RedirectHandler.handleCodeResponseFromHash (RedirectHandler.js:81:25)
at resolvePromise (zone.js:1211:31)
at zone.js:1118:17
at zone.js:1134:33
at _ZoneDelegate.invoke (zone.js:372:26)
at Object.onInvoke (core.mjs:26491:33)
at _ZoneDelegate.invoke (zone.js:371:52)
at Zone.run (zone.js:134:43)
at zone.js:1275:36
at _ZoneDelegate.invokeTask (zone.js:406:31)
at Object.onInvokeTask (core.mjs:26478:33)
MSAL Configuration
Relevant Code Snippets
Identity Provider
Azure B2C Custom Policy
Source
External (Customer)
please help to resolve this and I have gone through all you previous response but non of them helps me in order resolve the issue. I'm stuck in this issue almost 3 weeks.