# Use refresh token to keep auth0 session alive

**URL:** <https://community.auth0.com/t/use-refresh-token-to-keep-auth0-session-alive/132543>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [April 22, 2024, 5:59pm UTC](https://community.auth0.com/t/use-refresh-token-to-keep-auth0-session-alive/132543 "2024-04-22T17:59:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsteinbrunner](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jsteinbrunner/32/60041_2.png) [@jsteinbrunner](https://community.auth0.com/u/jsteinbrunner)\
**Post date:** [April 22, 2024, 5:59pm UTC](https://community.auth0.com/t/use-refresh-token-to-keep-auth0-session-alive/132543/1 "2024-04-22T17:59:04Z")

</div>

I wanted to confirm if there was any way to keep a user’s Auth0 session active from a server. The only approach I have been able to find to keep a session alive is by calling the `/authorize` endpoint.

I am able to read the state of a user’s session by using the `sid` value from the id token created during the `/token` request and can see the time it was created and last updated. I was hoping I could use the refresh token returned in the same `/token` request to refresh the token and affect the `updatedAt` value in the user’s session, but it doesn’t seem to work that way.

We are sharing an Auth0 tenant across multiple applications and are using the Auth0 session cookies to manage authentication between the systems. However, the inactivity timeout is preventing a user from authenticating to another system even when they have been active in the platform.

We would like to avoid performing `/authorize` calls in the browser to keep the Auth0 session active because we have restore state after the redirects. Do you have a recommendation for handling this situation? If there is no server side solution, do you recommend making silent auth calls in the background to keep the user’s Auth0 session active?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 22, 2024, 8:55pm UTC](https://community.auth0.com/t/use-refresh-token-to-keep-auth0-session-alive/132543/3 "2024-04-22T20:55:31Z")

</div>

Hey there @jsteinbrunner welcome to the community!

> [@jsteinbrunner](#):
>
> We would like to avoid performing `/authorize` calls in the browser to keep the Auth0 session active because we have restore state after the redirects. Do you have a recommendation for handling this situation? If there is no server side solution, do you recommend making silent auth calls in the background to keep the user’s Auth0 session active?

That’s exactly correct - You’ll want to look into utilizing [Silent Auth](https://auth0.com/docs/authenticate/login/configure-silent-authentication) and/or [Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens). Are you using a specific Auth0 SDK to auth users? This functionality is handled by all SDKs where possible.

---

<div class="post-metadata">

**Author:** ![jsteinbrunner](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jsteinbrunner/32/60041_2.png) [@jsteinbrunner](https://community.auth0.com/u/jsteinbrunner)\
**Post date:** [April 22, 2024, 11:45pm UTC](https://community.auth0.com/t/use-refresh-token-to-keep-auth0-session-alive/132543/4 "2024-04-22T23:45:53Z")

</div>

Thanks for the quick response!

With respect to Refresh Tokens, will refreshing the user’s token affect the inactivity timeout? I called the `/api/v2/sessions/{sessionId}` API after doing a refresh, and the `updatedAt` value remained unchanged. It is possible I made a mistake though.

We are currently using the Auth0 NextJS library to coordinate the user auth.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 23, 2024, 11:26pm UTC](https://community.auth0.com/t/use-refresh-token-to-keep-auth0-session-alive/132543/5 "2024-04-23T23:26:38Z")

</div>

No problem, happy to help where I can!

> [@jsteinbrunner](#):
>
> With respect to Refresh Tokens, will refreshing the user’s token affect the inactivity timeout? I called the `/api/v2/sessions/{sessionId}` API after doing a refresh, and the `updatedAt` value remained unchanged. It is possible I made a mistake though.

This is expected behavior - Refreshing tokens doesn’t affect the authentication session (IDP/Auth0 Level). The following topic does a good job explaining this:

> [@Refresh token lifetime and session length](https://community.auth0.com/t/refresh-token-lifetime-and-session-length/109722):
>
> Hi, Do I understand correctly that with Refresh Token we can allow user to be authenticated for 30 days without the need to go through the login form? Since we have Refresh TOken absolute lifetime set to 1296000 which is 30 days and Inactivity lifetime to 1296000 (15 days) a user should be forced to login every 15 days if not using the app and every 30 days when using the app?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 7, 2024, 11:27pm UTC](https://community.auth0.com/t/use-refresh-token-to-keep-auth0-session-alive/132543/6 "2024-05-07T23:27:02Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
