Refresh token grant errors with redis operational store #144
-
IdentityServer version7.0.5 .NET version8 DescriptionWe are using redis as a operational store for our identity server implementation and are seeing below errors. Any suggestions on what could be the probable root cause? [Duende.IdentityServer.Contrib.RedisStore.Stores.PersistedGrantStore] "<>" found in database: False We've set the refresh below parameters for the client configuration: Default 30 days token lifetime has been used for RefreshToken. Reproduction stepsNo specific steps to reproduce this issue. Happens randomly. Expected behaviorNo response LogsNo response Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Does this also occur when not using RedisStore? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the prompt response. We have not tried reproducing the same
scenario without RedisStore.
Here's the client configuration.
{
"ClientId": "<<clientId>>",
"AllowedGrantTypes": [ "authorization_code" , "password" ],
"RequirePkce": "true",
"RequireClientSecret": "false",
"AllowAccessTokensViaBrowser": "true",
"AllowOfflineAccess": "true",
"RequireConsent": "false",
"AlwaysIncludeUserClaimsInIdToken": "true",
"RefreshTokenUsage": "1",
"RefreshTokenExpiration": "1",
"AccessTokenLifetime" : "900",
"AllowedScopes": [ "openid", "profile" ],
"RedirectUris": [ "<<redirectUris>>" ],
"PostLogoutRedirectUris": [ "<<postLogoutRedirectUris>>" ],
"UpdateAccessTokenClaimsOnRefresh": "true"
},
…On Wed, Apr 2, 2025 at 3:08 PM RolandGuijt ***@***.***> wrote:
Does this also occur when not using RedisStore?
If so: can you please share the complete client configuration and the code
around how the client is configured?
If not please create an issue in the GitHub project
<https://github.com/safe-fleet/Duende.IdentityServer.Contrib.RedisStore>.
The project has "Duende" in its name but it's not maintained by us.
—
Reply to this email directly, view it on GitHub
<#144 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADLVPK5PF5MDIESFTIV5YW32XOVZVAVCNFSM6AAAAAB2I3KACOVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENRZHA2TCNA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
We were able to reproduce this issue when we had more than 1 tab open for the same user in single browser instance. Is it that when 2 tabs are open, the 2nd tab uses refresh token from the first tab, to renew the access token? and then when first tab tries to renew the token using his older refresh token, it is not found in redis store [since we have kept refreshTokenUsage as OneTime]? |
Beta Was this translation helpful? Give feedback.
-
It depends on how the tokens are stored. |
Beta Was this translation helpful? Give feedback.
-
We probably figured out the root cause of the issue. It was happening when same user opens the client in 2 tabs in same browser instance. i.e. if user opens tab 01, Access token A1 and Refresh Token R1 was issued to it. When he opened tab 02, refresh token R1 was being sent to get new Access token A2 and Refresh Token R2. Now, when tab 01 access token A1 was nearing expiry, it was making a call with same refresh token R1 to get new tokens. However, since we had "RefreshTokenUsage" set to OneTime, that token was already consumed. Hence, we were getting "invalid_grant" errors on first tab. |
Beta Was this translation helpful? Give feedback.
We probably figured out the root cause of the issue. It was happening when same user opens the client in 2 tabs in same browser instance. i.e. if user opens tab 01, Access token A1 and Refresh Token R1 was issued to it. When he opened tab 02, refresh token R1 was being sent to get new Access token A2 and Refresh Token R2. Now, when tab 01 access token A1 was nearing expiry, it was making a call with same refresh token R1 to get new tokens. However, since we had "RefreshTokenUsage" set to OneTime, that token was already consumed. Hence, we were getting "invalid_grant" errors on first tab.