You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inquiry: OIDC Web Flow - state Not Found After Redirect
Description:
I'm working on a Flutter web app using the OIDC Flutter package for authentication. After logging in, the app redirects to the redirect.html page, which displays the message:
"Operation Successful! Please close this page."
However, when I close this tab and return to the original login page, the login flow does not complete, and I see the following error message in the browser console:
handleRedirect - state not found, key: 944ef68e-0b29-4fe0-8054-f56e8832cfca
It seems that the state parameter is not being saved or retrieved correctly from localStorage, which is causing the authentication process to break after redirection.
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><title>Flutter Oidc Redirect</title><metaname="viewport" content="width=device-width, initial-scale=1.0"><scripttype="text/javascript">conststateNamespace='state';conststateResponseNamespace='response.state';constrequestNamespace='request';constrequestBroadcastChannel='oidc_flutter_web/request';constredirectBroadcastChannel='oidc_flutter_web/redirect';if(!handleFrontChannelLogout()){handleRedirect();}functionhandleRedirect(){varbc=newBroadcastChannel(redirectBroadcastChannel);bc.postMessage(window.location.toString());bc.close();letdataSrc=newURLSearchParams(window.location.search);varstate=dataSrc.get('state');if(!state&&window.location.hash){dataSrc=newURLSearchParams(window.location.hash.substring(1));state=dataSrc.get('state');}if(!state){console.error('state not found, key: '+state);return;}conststateDataRaw=getLocalStorage(stateNamespace,state);if(!stateDataRaw){console.error('state data not found, key: '+state);return;}setLocalStorage(stateResponseNamespace,state,window.location.toString());constparsedStateString=JSON.parse(stateDataRaw);if(!parsedStateString){console.error('parsed state is null');return;}constwebLaunchMode=parsedStateString.options?.webLaunchMode;if(!webLaunchMode){console.error('webLaunchMode not found in parsed state.');return;}if(webLaunchMode!='samePage'){return;}constoriginal_uri=parsedStateString.original_uri;if(!original_uri){console.warn("It's preferred that original_uri is used when webLaunchMode is samePage.");return;}window.location.assign(original_uri);}functionhandleFrontChannelLogout(){constqueryParams=newURLSearchParams(window.location.search);if(queryParams.get('requestType')=='front-channel-logout'){varbc=newBroadcastChannel(requestBroadcastChannel);bc.postMessage(window.location.toString());bc.close();setLocalStorage(requestNamespace,'front-channel-logout',window.location.toString());returntrue;}returnfalse;}functiongetLocalStorage(namespace,key){constrawRes=localStorage.getItem('oidc.'+namespace+'.'+key);if(!rawRes){returnnull;}returnrawRes;}functionsetLocalStorage(namespace,key,value){constkeysEntryKey='oidc.keys.'+namespace;varkeys=localStorage.getItem(keysEntryKey);if(!keys){keys="[]";}constparsedKeys=JSON.parse(keys);if(!(parsedKeysinstanceofArray)){console.error('parsedKeys is not an array.',parsedKeys);}parsedKeys.push(key);localStorage.setItem(keysEntryKey,JSON.stringify(parsedKeys));localStorage.setItem('oidc.'+namespace+'.'+key,value);}</script></head><body><h3>Operation Successful! Please close this page.</h3></body></html>
Steps to Reproduce:
Start the Flutter web app.
Click the login button, which redirects to the identity provider.
After successful login, the redirect.html page is shown with the message: "Operation Successful! Please close this page."
Close the tab, but notice that the app does not update and the login state remains unrecognized.
What I’ve Tried:
Verified the redirect.html is being correctly served.
Checked that BroadcastChannel is working properly.
Ensured that the same broadcast channel name is used across the Flutter app and redirect.html.
Any advice or help on how to resolve this issue would be greatly appreciated.
The text was updated successfully, but these errors were encountered:
@CuriousDev21 when the Operation Successful! Please close this page is displayed, can you check the existing local storage values ? you can see them in F12 -> Application tab > Local Storage
Inquiry: OIDC Web Flow -
state
Not Found After RedirectDescription:
I'm working on a Flutter web app using the OIDC Flutter package for authentication. After logging in, the app redirects to the
redirect.html
page, which displays the message:"Operation Successful! Please close this page."
However, when I close this tab and return to the original login page, the login flow does not complete, and I see the following error message in the browser console:
It seems that the
state
parameter is not being saved or retrieved correctly fromlocalStorage
, which is causing the authentication process to break after redirection.Setup Details:
http://localhost:3000/redirect.html
OIDC manager setup:
Here is the content of the
redirect.html
file:Steps to Reproduce:
redirect.html
page is shown with the message: "Operation Successful! Please close this page."What I’ve Tried:
redirect.html
is being correctly served.BroadcastChannel
is working properly.redirect.html
.Any advice or help on how to resolve this issue would be greatly appreciated.
The text was updated successfully, but these errors were encountered: