Controlling Access Token Expiration

By default, the access token is set to expire after 30 days. However, you can easily modify this value to suit your needs.

To change the access token expiration time, locate the following line in the authorization_server.service.ts file:

The DateInterval class is used to specify the duration of the access token. In this example, '30d' means 30 days.

Modifying the Access Token Expiration

To modify the access token expiration time, simply change the value passed to the DateInterval constructor. You can use the following format:

  • 'Xd' for days (e.g., '10d' for 10 days)

  • 'Xh' for hours (e.g., '6h' for 6 hours)

For example, to set the access token expiration to 7 days, you would change the line to:

new DateInterval('7d')

Similarly, to set the expiration to 2 hours, you would use:

new DateInterval('2h')

Feel free to adjust the value according to your specific requirements. Just remember to update the DateInterval constructor in the authorization_server.service.ts file.

That's it! With this simple modification, you can easily control the lifespan of the access tokens in your application.

Last updated