Closed slabiakt closed 1 month ago
make sure AuthProvider
comes before RouterProvider
@pamapa I used metadata key in the config to avoid using CORS and also have a redirection problem
export const oidcConfig = {
authority: GAS_BASE_URL,
client_id: process.env.REACT_APP_GAS_CLIENT_ID,
redirect_uri: process.env.REACT_APP_GAS_CALLBACK_URL,
scope: 'openid profile group_type email',
onSigninCallback: (user) => {
console.log('onsignin', user);
window.history.replaceState({}, document.title, '/');
window.location.reload();
},
userStore: new WebStorageStateStore({ store: window.localStorage }),
metadata: {
issuer: GAS_BASE_URL,
authorization_endpoint: GAS_BASE_URL + '/as/authorization.oauth2',
userinfo_endpoint: GAS_BASE_URL + '/idp/userinfo.openid',
end_session_endpoint: GAS_BASE_URL + 'idp/startSLO.ping'
}
};
log "onsignin" never fires. And in the console there is nothing but a warning: "No routes matched location "/callback?code=F8...78ca17e..asd".
The provider comes before Router:
root.render(
<AuthProvider {...oidcConfig}>
<BrowserRouter>
<Routes>
...
any ideas why redirection doesn't happen? Without metadata and with "CORS Unblock" extension everything works fine
UPDATED: Enabled logs and getting
Logger.ts:89 [OidcClient] readSigninResponseState: Error: No matching state found in storage
maybe a configuration is wrong, weird
UPDATED:
I added token_endpoint: GAS_BASE_URL + '/as/token.oauth2'
parameter, now it's just getting stuck on a callback page with a CORS error to this /as/token.oauth2
URL.
And I'm wondering, is it a bug in this lib or on an SSO authority side? Because in the docs oidc-client-ts it says: just add metadata to solve CORS issue. I added, didn't help :)
Logger.ts:89 [OidcClient] readSigninResponseState: Error: No matching state found in storage
That is the redirect callback call and it can somehow not match the data with the previously stored sigin request data, you will need to find out why...
Did you try using withAuthenticationRequired
? See README
This issue (question) staled some time ago, closing it for now.
Hi, I use react v18, router v6 and this library. Without router everything works as expected however with router i have this problem that when i try to enter protected route /admin directly from browser then auth.isAuthenticated is false, but when I enter this path via
<Naviage to="/admin">
then auth.isAuthenticated is still set to true. When I don't use RouteAuthGuard and enter directly to /admin then auth context is resolved from local storage but with RouteAuthGuard it seems that it can't resolve auth from local storage and auth is set to false.any idea why?