The Tokens tab in Keycloak allows you to configure settings related to token lifespans, authorization flows, refresh tokens, and user actions.
This guide explains each configuration option in detail to help you manage security and session behaviors effectively.
Fig 3.9.10.a: Token Configuration and Management
Default Signature Algorithm
Purpose: Defines the algorithm used to sign tokens for the realm.
Default: RS256
How to Configure:
Select an algorithm from the dropdown menu according to your security and compatibility requirements.
Short Verification URI (Device Authorization Flow)
Purpose: Specifies the short verification URL returned during the Device Authorization flow.
Usage: Helps users quickly access the verification page on secondary devices.
Revoke Refresh Token
Purpose: Controls whether refresh tokens should be revoked after a certain number of uses.
Behavior:
Enabled (ON) → Refresh tokens are revoked after reaching the Refresh Token Max Reuse limit.
Disabled (OFF) → Refresh tokens remain valid for multiple uses without revocation.
Fig 3.9.10.e: Token, Revoke refresh token
This is a toggle button, when activated (toggled ON), refresh tokens are revoked after reaching Refresh Token Max Reuse (which can be customized as per your requirements), allowing their use until then. Otherwise, refresh tokens are not revoked and they remain valid for multiple uses.
When deactivated (toggled OFF), they function as usual without revocation.
Fig 3.9.10.f: Token, Refresh token
Refresh Token Max Reuse
Purpose: Defines the maximum number of times a refresh token can be reused before being revoked.
Configuration:
Available only when Revoke Refresh Token is enabled.
Adjust the value using the arrow buttons.
Fig 3.9.10.f: Token, Access token
Access Token Lifespan
Purpose: Specifies how long an Access Token remains valid before expiration.
Recommendation: Set this shorter than the SSO session timeout for better security.
Configuration: Adjust the duration and choose the unit (Minutes, Hours, or Days).
Fig 3.9.10.g: Token, Access token lifespan
This defines the maximum lifespan of an Access Token before it gets expired.
It is mostly recommended to keep this shorter than the SSO Timeout duration.
You can adjust the values and select the duration unit from the dropdown menu as required.
8. Access Token Lifespan (Implicit Flow)
Purpose: Sets the lifespan for Access Tokens generated during the OpenID Connect Implicit Flow.
Important:
Tokens issued in this flow cannot be refreshed.
Recommended to set a shorter duration than the regular access token lifespan.
Fig 3.9.10.h: Token, Access token lifespan for implict flow
This is the maximum lifespan for Access Tokens generated during the OpenID Connect Implicit Flow.
This value is recommended to be shorter than the SSO Timeout.
Unlike other flows, tokens here cannot be refreshed, that is why this is a separate timeout different to Access Token Lifespan.
You can adjust the values and select the duration unit from the dropdown menu as required.
9. Client Login Timeout
Purpose: Sets the maximum duration for clients to complete the Authorization Code Flow in OpenID Connect.
Recommendation: Keep it short — typically 1 minute.
Configuration: Adjust the duration and select the unit from the dropdown.
Fig 3.9.10.i: Token, Client login timeout
This refers to the maximum duration for clients to complete the Authorization Code Flow in OIDC
It is typically recommended to be about 1 minute.
You can adjust the values and select the duration unit from the dropdown menu as required.
Fig 3.9.10.j: Token, Action token
10. User-Initiated Action Lifespan
Purpose: Specifies how long a user action token remains valid.
Examples: Forgot Password, Verify Email.
Recommendation: Set a short duration since these actions are expected to be completed quickly.