oidc-client
oidc-client copied to clipboard
userInfo not available immediately after authentication
Issue and Steps to Reproduce
Hi, Thank you first of all for the well maintained library.
We are running a React based SPA with secure routes using OidcSecure
. All the routes are correctly secured. But after the authentication, we have our custom authorization step based on the roles in the OidcUserInfo
.
We used the hook useOidcUser
to fetch user information.
But the "userInfo" is still null after the authentication is completed. Is there way to wait for userInfo to be fully instantiated after the authentication is completed and before the control continues to next React component?
useOidc -> this hook returns isAuthenticated
true.
Thank you
Config -
authority: xxxx,
client_id: xxxxx,
redirect_uri: window.location.origin + "/authentication/callback",
silent_redirect_uri: window.location.origin + "/authentication/silent-callback",
scope: xxxx
Versions
├── @axa-fr/[email protected] ├── [email protected] ├── [email protected] ├── [email protected]
Screenshots
We can see here that the token itself is there. but userinfo is still null.
console.log(oidcUser)
console.log(oidcUserLoadingState)
console.log(idTokenPayload)
Expected
oidcUser is not null after authentication is completed.
Actual
oidcUser is null after authentication is completed.
Additional Details
- Installed packages:
Hi @swaroopar , Thank you for your issue.
I think it is possible to do it. user information comes from a fetch, but I think it is possible to hide it.
Hi @guillaume-chervet thank you for your quick response. Would be great to have it. So that the details can be used immediately after authentication.
Hi,
@guillaume-chervet I'm encountering the same issue where I need to display the user's name, role, and other relevant information retrieved from the OIDC user object right after authentication. In version 3, there was a configuration property called loadUserInfo that's no longer available. Are there any alternative approaches to achieve this in the current version?
hi @attiqeurrehman , I will try to add it tomorrow. It is a prettry quick feature to add.
@guillaume-chervet any update on this?
Sorry @attiqeurrehman , I will try to do it today or friday 😀
No problem and sounds like a plan.
Hi @attiqeurrehman , version v7.22.4-alpha.1423 implement a preload_user_info : true Configuration property
Will use it tomorrow and let you know.