# 3.9.10 Tokens

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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FmBtU8wmixk9Qx7dswgS3%2F16.png?alt=media&#x26;token=2f7f2b87-b7ff-45eb-a3a7-1eaecd04edd3" alt=""><figcaption></figcaption></figure>

1. **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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FyW0ZgWp5r5nHgcojx9r3%2F17.png?alt=media&#x26;token=fcfea59c-d661-4490-afa7-5142f98c4b7b" alt=""><figcaption></figcaption></figure>

You can choose the most suitable option from the dropdown menu based on your needs.

2. **OAuth 2.0 Device Code Lifespan**
   * **Purpose**: Sets the maximum lifespan of the **device code** and **user code** before they expire.
   * **Recommendation**:
     * Keep it long enough to allow users to retrieve their secondary device, navigate to the verification URL, and log in.
     * Keep it short enough to minimize risks like phishing or code misuse.
   * **Configuration**: Adjust the duration using the input field and select the unit (**Seconds, Minutes, Hours, or Days**) from the dropdown.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FYyX2I4m9HIG8IAIamYrZ%2F18.png?alt=media&#x26;token=9db8f09a-b28a-47be-85c5-b35cb3b08a6e" alt=""><figcaption></figcaption></figure>

3. **OAuth 2.0 Device Polling Interval**

* **Purpose**: Defines the waiting period (in **seconds**) between successive polling requests to the token endpoint.
* **Recommendation**: Set an appropriate value to balance responsiveness and server load.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2F2jQXTQ3eNk2Sj9zGT7hl%2F19.png?alt=media&#x26;token=2431aad2-ab6b-420b-9b30-8daa6c8faaec" alt=""><figcaption></figcaption></figure>

4. **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.

5. **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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FAE2Goo4NJ9vvj73g1unj%2F20.png?alt=media&#x26;token=572153dd-4f07-4c3a-87cd-4b36d4df4689" alt=""><figcaption></figcaption></figure>

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.&#x20;

When deactivated (toggled OFF), they function as usual without revocation.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FIrNsbCRHNDzQnkHYIEJG%2F22.png?alt=media&#x26;token=a17c318a-f592-4c97-a851-d410ab1941df" alt=""><figcaption></figcaption></figure>

6. **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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FSuld1Lef8pbbyLnj5Pvm%2F23.png?alt=media&#x26;token=f2a1b875-5e52-4431-9325-f1a3a5c2ece7" alt=""><figcaption></figcaption></figure>

7. **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**).

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FkzCuDte5FVuzWOJrJeuc%2F24.png?alt=media&#x26;token=6891467e-1330-4956-88b0-54861e442d47" alt=""><figcaption></figcaption></figure>

This defines the maximum lifespan of an Access Token before it gets expired.&#x20;

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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FRQm5ff35AU806k8abIUO%2F25.png?alt=media&#x26;token=74b57bbe-971c-4ffa-a670-1fc9599d273a" alt=""><figcaption></figcaption></figure>

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.&#x20;

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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2F3W9kflOGRZHjk6pcBfhA%2F26.png?alt=media&#x26;token=0bdf6b18-57de-4121-a109-1cba621dd4dd" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FVlV790tlMxTUbjFGWttk%2F27.png?alt=media&#x26;token=236c3af9-fcbf-439d-937b-04e3e3ef9e8e" alt=""><figcaption></figcaption></figure>

#### **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.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FYjKikj7Un9CBuVULwxqH%2F28.png?alt=media&#x26;token=d2f78ad1-4294-45f7-9f65-d95e7e2695d0" alt=""><figcaption></figcaption></figure>

This refers to the maximum time after which a user's action permission (such as a Forgot Password email) expires.

It's kept short as users are expected to respond to such actions promptly.

You can adjust the values and select the duration unit from the dropdown menu as required.

#### **11. Default Admin-Initiated Action Lifespan**

* **Purpose**: Defines the validity period of action tokens sent by administrators.\
  Examples: **Update Password**, **Verify Email**.
* **Recommendation**: Keep this **longer** to support offline users.
* **Configuration**: Administrators can modify this before sending tokens.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FB4wFbIi2lEoP8boCsOUq%2F29.png?alt=media&#x26;token=7d0f5942-dfe0-4ac9-95cc-4407e434cc10" alt=""><figcaption></figcaption></figure>

This refers to the maximum duration before an action permit sent by the administrator to the user expires.&#x20;

It's recommended to keep this duration long to accommodate offline users.&#x20;

Administrators can adjust this timeout before issuing the token.

#### **12. Email Verification Timeout**

* **Purpose**: Sets the expiration time for **email verification links**.
* **Configuration**: Adjust based on your security policies.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2F7sH5RqeKnmv4Hxys5iZg%2F30.png?alt=media&#x26;token=40b2d49a-b979-44b6-b81c-17a5a2cc14f0" alt=""><figcaption></figcaption></figure>

This sets a separate timeout for email verification. You can adjust this setting according to your needs.

#### **13. IdP Account Email Verification Timeout**

* **Purpose**: Defines a **separate timeout** for verifying email addresses associated with **Identity Providers (IdP)**.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FUtVmF5m7632afDyY345v%2F31.png?alt=media&#x26;token=542e6d97-7b0d-4075-a4d8-3a5b9d442bd0" alt=""><figcaption></figcaption></figure>

This sets a separate timeout for Identity Provider (IdP) account email verification. You can customize this setting according to your needs.

14. **Forgot Password Timeout**

* **Purpose**: Sets the timeout for **forgot password** requests.
* **Recommendation**: Keep it short to ensure security.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2FpfiDAPW4GFjjHMThpcFN%2F32.png?alt=media&#x26;token=3772d0cb-bbe8-4615-ad9d-7e543bbfefb5" alt=""><figcaption></figcaption></figure>

This sets a separate timeout for forgot password requests. You can customize this setting according to your needs.

#### **15. Execute Actions Timeout**

* **Purpose**: Defines the timeout for completing **admin-triggered actions** like password updates or configuring MFA.

<figure><img src="https://1778922777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3EUK5AUZv0UVaI5S0CTM%2Fuploads%2F1pBRLIPf6RYbOj3scvAh%2F33.png?alt=media&#x26;token=8e34bc78-e3c8-494d-819c-d403e5112552" alt=""><figcaption></figcaption></figure>

This sets a separate timeout for executing actions. You can customize this setting according to your needs.

### **Save and Revert**

* **Save**: Applies all changes you’ve made in the **Tokens** tab.
* **Revert**: Discards any unsaved modifications and restores the previous configuration.
