AxaFrance / oidc-client

Light, Secure, Pure Javascript OIDC (Open ID Connect) Client. We provide also a REACT wrapper (compatible NextJS, etc.).
MIT License
582 stars 160 forks source link

ID Token undefined after renewing tokens #1270

Closed leonardo-asad closed 8 months ago

leonardo-asad commented 8 months ago

Issue and Steps to Reproduce

After the initial authentication process I am able to get the id_token in my react application using the following hook:

const { idToken, idTokenPayload } = useOidcIdToken();

After 15 minutes, the access token expires and the tokens are renewed normally. The body of the response does not include the ID Token. After this if I try to get the idToken the value will be undefined and for the ID Token Payload the value will be null.

I think that the problem might be that the library is expecting to have the idToken in the response body each time we renew the token. I researched and I found out that the idToken is optional in the response after successfully renewing the tokens:

image

Versions

"@axa-fr/react-oidc": "^7.13.15"

Screenshots

image

Expected

Being able to get the idToken and idToken Payload

Actual

After renewing the access token, the idToken is undefined and the idToken payload null.

Thank you !!

guillaume-chervet commented 8 months ago

Ho thank you for your issue @leonardo-asad .

It is the same for the refreshToken. I did not know that. I will try to fix it quickly !

guillaume-chervet commented 8 months ago

hi @leonardo-asad ,

You can test version 7.15.0-alpha.1286 that may fix that :)

leonardo-asad commented 8 months ago

hi @guillaume-chervet

Thanks for your quick response !

It seems that this new version fixes the problem

Thanks!

guillaume-chervet commented 8 months ago

Version is published as 7.15.1 @leonardo-asad . Thank you very much for your help ! feel free to close the Issue :)

OrtakProje-1 commented 4 months ago

Hi @guillaume-chervet

I still encounter this problem.

When you go from the parseOriginalTokens method to the setTokens method, the condition !('idToken' in tokens) always returns false, because the tokens object always contains idToken.

image

Please feel free to correct me if I'm wrong

Versions "@axa-fr/react-oidc": "^7.22.6"