Skip to main content
Skip table of contents

KeyCloak Token Lifespan Configuration

This document elaborate the process of configuring the lifespan of access and refresh token. Below are the steps to configure token lifespan:

  1. First check the lifespan of your access and refresh token. This is the Postman API call to generate admin token, you can see that it has lifespan for both tokens is 30 minutes.

    Untitled design.png
  2. Now, go to your targeted realm in keycloak and then click on Realm Settings under Configure tab (in this example its Expertflow).

    Screenshot from 2025-04-23 19-15-52.png
  3. Click on Session tab in Realm Settings. “SSO Session Idle” set the time of refresh token expiry. By default, it is configured to 30 minutes. Change it to your desired span.

    Screenshot from 2025-04-23 19-16-07.png
  4. Now, click on Clients tab under Manage setting on left panel, then click on cim.

    Screenshot from 2025-04-23 19-16-32.png
  5. Click on Advanced tab in cim settings

    Screenshot from 2025-04-23 19-16-42.png
  6. Scroll down until you see Advanced Settings. Under which we can see Access token lifespan setting. This setting modifies the lifespan of our access token. Modify its duration to your liking, by default its 30 minutes.

    Screenshot from 2025-04-23 19-16-56.png
  7. After changing both access and refresh token lifespan to our liking (for this example i changed them to 1 day). You can confirm by calling the Keycloak token API and verify that changes are persisting.

    Screenshot from 2025-04-23 19-18-12.png
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.