Skip to content

Rotated Refresh Token Validity

0

I have enabled Cognito App Client to have refresh token rotation. Using the js sdk, I am able to make requests to rotate tokens by using current refresh token and command GetTokensFromRefreshTokenCommand. I am getting new tokens (all 3) on each call but once the session passes an hour mark which is what I have set refresh token validity as the sdk returns refresh token expired. I have access token valid for 15mins and refresh token for 60mins. Making 3 calls within the hour there is no issue but after the hour mark sdk returns token expired. I was under the impression that the validity of refresh token would change every time it was issued to be valid for an hour after it was issued - is that no correct? Lib version is 3.914.0

2 Answers
0
Accepted Answer

The behavior you're experiencing is expected. When you set the RefreshTokenValidity to 60 minutes (1 hour), this represents the absolute time limit for your refresh token, measured from when the user initially authenticates - not from when the token is rotated.

Even though you're using refresh token rotation and receiving new tokens with each call to GetTokensFromRefreshTokenCommand, the overall refresh token lifetime remains fixed at your configured value (60 minutes). The rotation provides you with new token values, but doesn't extend the original expiration window.

After your configured RefreshTokenValidity period (1 hour) has elapsed, the refresh token will expire regardless of how many times it was rotated within that window. At that point, your user would need to authenticate again to get a new set of tokens.

If you need your users to maintain longer sessions without re-authentication, you should increase the RefreshTokenValidity setting. The default is 30 days, and you can configure it with time units of seconds, minutes, hours, or days by setting the appropriate TokenValidityUnits value in your request.
Sources
UserPoolClientType - Amazon Cognito User Pools
UserPoolClientType (AWS SDK for Java - 2.21.29)
UpdateUserPoolClient - Amazon Cognito User Pools

answered a year ago

EXPERT

reviewed a year ago

0

🔐 What Is Rotated Refresh Token Validity?

Rotated Refresh Token Validity refers to the time duration for which an old refresh token remains valid after it has been rotated (replaced) during authentication.

🟦 What is Refresh Token Rotation?

In modern authentication systems (like OAuth 2.0 or OpenID Connect):

When a user uses a refresh token to get a new access token…

The auth server invalidates the old refresh token and issues a new refresh token.

This process is called refresh token rotation.

It improves security by preventing token reuse attacks.

🟩 So What Is "Rotated Refresh Token Validity"?

It means:

How long the previous refresh token can still be used after rotation, before it becomes invalid.

Example: If the rotated refresh token validity = 3 minutes, then:

You use Refresh Token A

Server gives you Refresh Token B

Refresh Token A is still valid for 3 more minutes

After 3 minutes, only Refresh Token B can be used

🟧 Why Is This Important?

✔ Prevents token theft attacks If a stolen token is used after the validity window → it gets rejected.

✔ Improves session security Only one refresh token remains valid at a time.

✔ Supports recovery from race conditions E.g., when multiple devices or network delays cause tokens to overlap.

🟩 Typical Values

Different systems set different values:

0 seconds → Old token expires immediately

30 seconds – 5 minutes → Common setting

10 minutes → Rare, but can be used when dealing with slow mobile network

🏁 In Simple Words

Rotated Refresh Token Validity = Grace period for the old refresh token after issuing a new one.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.