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:
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.
Now, go to your targeted realm in keycloak and then click on Realm Settings under Configure tab (in this example its Expertflow).
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.
Now, click on Clients tab under Manage setting on left panel, then click on cim.
Click on Advanced tab in cim settings
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.
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.