oidc-client: State not valid (expected: ..., received: ...)
Issue and Steps to Reproduce
I’m trying to re-authenticate the user in the SessionLost Component when the users logs out in the same application on a different tab.
`export const SessionLost = () => { … oidc.loginAsync(location.href, { ‘login_hint’: userEmail }); …
}; ` After the call, the authorize endpoint of our identity server is called with a new state value, the same state is returned to the callback url of my application.
But then i get the error, that an old state is expected, not the new one:
suppress-nextjs-warning.ts:7 Error: State not valid (expected: jHR5nIRPKTpJEijI, received: 4KePHGMLAGCwNBxn) at index.js:1310:13
Am i using the loginAsync method wrong? We are using the service worker mode.
Versions
7.22.24
Screenshots
Expected
Actual
Additional Details
- Installed packages:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (7 by maintainers)
I have same error with different flow, can you please check this video? @guillaume-chervet
https://www.loom.com/share/de5e6ec2c0e3498f981b711ccd3adacc?sid=ebe7c1f4-3cce-4c7e-9c6d-4a2b40f3f96a
Flow is: Open two different tab for application and try login for firsat one. Second one (last opening one) is working but first one is not working. You can see in the loom video. Thanks
Yes
Oh thank you @bernhard-braeu i understood ypur flow. I will make sime test today to try to reproduce it!
Everything else from your library just works perfectly fine! Its just this special issue to automatically start the login flow when the session is lost (in our case when the user logs out in the same application in another tab).
We are using the OidcProvider and implemented all components on our own:
In the session lost component i’m trying to start the login flow automatically with some extra parameters for our Identity Server to know which user it should try to automatically log in: