oidc-client: `renewTokens()` fails silently without throwing an error
Issue and Steps to Reproduce
When we perform an API call, we use the accessToken
and send it to our API endpoint. If the response status is a 401, we refetch the latest accessToken by using the renewTokens()
method. Since this method is a promise, we do wait for it and then reperform the API that initially returned a 401.
Now this method seems to eat the error when there is a peculiar scenario where we have the accessTokenPaylod like the following:
"accessTokenPayload": {
"exp": 1701898951,
"iat": 1701895411,
...
}
Apparently, the exp
and iat
are well before current UNIX timestamp. Therefore what happens is, the method fails (I suppose - not 100% sure). Because of it, we are unable to get the token for re-firing the API.
Versions
7.12.2
Screenshots
Expected
The method should return the valid accessToken
instead of failing silently.
Actual
The method fails silently
Additional Details
- Installed packages:
About this issue
- Original URL
- State: open
- Created 7 months ago
- Comments: 18 (12 by maintainers)
I will look at the renew token return an ild tokens. Why do you use this method? In fact the library renew tokens automaticaly.
Yes i have to manage the not connected to internet case. I think i have an idea to test.
I this we need to test with an abort controller instead of ifavailable. With a timeout longer than refresh timeout and silentsigin timeout. But it is not simple because of retry integrated. It should be moved to an upper level.
Hi @abhilashlr very sorry for the delay, i have been stick this week.
The refresh_time_before_tokens_expiration_in_second will trigger the refresh of the tokens this time before expiration.
I think the if window available make the original problem back. I have to find a solution to remove local on sleeping Window or tab. I will read more the documentation about this.