# Need help changing token expiration time in Authentication API response

**URL:** <https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [April 6, 2023, 2:47pm UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251 "2023-04-06T14:47:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenkoooo-estie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kenkoooo-estie](https://community.auth0.com/u/kenkoooo-estie)\
**Post date:** [April 6, 2023, 2:47pm UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/1 "2023-04-06T14:47:26Z")

</div>

Hello there!

I’ve been working with an Authentication API, but I’m having some trouble with the token expiration time.

Currently, the `expires_at` value in the response from `oauth/token` is always set to `now + 86400`, which equates to 24 hours. I was wondering if there’s any way to change this value to better suit my project’s needs. I’ve attempted to modify the Token Expiration of the Auth0 Management API, but unfortunately, it didn’t seem to affect the returned value.

If anyone has any suggestions or solutions to this issue, I would greatly appreciate your help. Thank you!

---

<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 6, 2023, 11:08pm UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/3 "2023-04-06T23:08:08Z")

</div>

Hello there @kenkoooo-estie welcome to the community!

> [@kenkoooo-estie](#):
>
> Currently, the `expires_at` value in the response from `oauth/token` is always set to `now + 86400`, which equates to 24 hours. I was wondering if there’s any way to change this value to better suit my project’s needs. I’ve attempted to modify the Token Expiration of the Auth0 Management API, but unfortunately, it didn’t seem to affect the returned value.

Which kind of token are you referring to here specifically? [ID token](https://auth0.com/docs/secure/tokens/id-tokens), [Access Token](https://auth0.com/docs/secure/tokens/access-tokens) (external API audience) or [Management API Access Token](https://auth0.com/docs/secure/tokens/access-tokens/management-api-access-tokens)?

Let us know!

---

<div class="post-metadata">

**Author:** ![kenkoooo-estie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kenkoooo-estie](https://community.auth0.com/u/kenkoooo-estie)\
**Post date:** [April 7, 2023, 1:28am UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/4 "2023-04-07T01:28:16Z")

</div>

Thank you for your response! Let me provide some additional details.

I am currently utilizing the `@auth0/nextjs-auth0` library to retrieve the ID Token. This library sends a request to the `/oauth/token` endpoint and extracts the ID Token from the response. It also retrieves the `expires_at` value from the response, which is used by the library to determine whether the token has expired or not. Once the token has expired, the library will refresh it by sending another request to the `/oauth/token` endpoint.

It’s possible to modify the expiration time of the ID Token within the management console. This will result in a modification of the `exp` value within the ID Token JWT, but the `expires_at` value will remain unchanged.

Is it possible to modify the `expires_at` value? I don’t think it’s currently possible to do so.

---

<div class="post-metadata">

**Author:** ![kenkoooo-estie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kenkoooo-estie](https://community.auth0.com/u/kenkoooo-estie)\
**Post date:** [April 7, 2023, 8:17am UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/5 "2023-04-07T08:17:40Z")

</div>

Sorry, I misunderstood the field name. The actual field name returned by the endpoint is `expires_in` and `expires_at` is calculated by `openid-client`.

So, the question is:  
Is it possible to modify the `expires_in` value?

---

<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 8, 2023, 12:56am UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/6 "2023-04-08T00:56:06Z")

</div>

Thanks for all the detailed information, very helpful!

`expires_in` is in relation to the access token’s expiration and not the ID token - If I am understanding your question correctly, you should be able to adjust this time by changing the token expiration of the access token in the relevant API settings. In your dashboard this can be done at Application → APIs → Settings → Token Settings:

 ![Screenshot 2023-04-07 at 5.55.43 PM](https://global.discourse-cdn.com/auth0/original/3X/7/b/7bb552e344b77f59e200565de6733e33e192c690.jpeg)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![kenkoooo-estie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kenkoooo-estie](https://community.auth0.com/u/kenkoooo-estie)\
**Post date:** [April 8, 2023, 2:08pm UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/7 "2023-04-08T14:08:48Z")

</div>

Thank you for your suggestion, but unfortunately, it did not resolve my issue. Let me explain how to reproduce the problem:

1. Create a new tenant, which will have one default application and the “Auth0 Management API”.
2. Delete the default application and create a new “Regular Web Application”.
3. Configure the web app and log in via Auth0.
4. You will receive a session with an `idToken`, `accessTokenExpiresAt`, and other fields. The value of `accessTokenExpiresAt` will be `now + 86400`, as previously described.

I’ve attempted to modify the Token Expiration of the Auth0 Management API, but unfortunately, it didn’t seem to affect the returned value. The “Token Expiration for Browser Flows (Seconds)” field exists within the Auth0 Management API, but any modifications made to it were not accepted. The attached image shows that the field’s value is 7200.

 ![Screenshot 2023-04-08 at 23-00-45 API Details](https://global.discourse-cdn.com/auth0/original/3X/9/6/9665b1417a6ea6d53219d1e6bd5c7aef37d14a31.png)

Do you have any ideas on how to resolve this issue? If you require further information, please let me know.

Thank you!

---

<div class="post-metadata">

**Author:** ![kenkoooo-estie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kenkoooo-estie](https://community.auth0.com/u/kenkoooo-estie)\
**Post date:** [April 20, 2023, 7:34am UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/8 "2023-04-20T07:34:27Z")

</div>

Hello, @ty.frith  
The issue is still ongoing. Would it be possible to suggest a solution or a workaround?

---

<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 20, 2023, 9:38pm UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/9 "2023-04-20T21:38:10Z")

</div>

Hi there @kenkoooo-estie sorry for the delay on this one - I am as of now unable to reproduce. Do you mind sharing here a sample access token? Please redact any sensitive information.

Do you see these changes (300 second expiration time) for the Management API token retrieved in any way listed in the “Test” tab? I just tested `Curl` and `Node.js` and do indeed see the correct expiration time reflected in the token.

---

<div class="post-metadata">

**Author:** ![peter.fernandez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/peter.fernandez/32/45477_2.png) [@peter.fernandez](https://community.auth0.com/u/peter.fernandez)\
**Post date:** [April 28, 2023, 9:26am UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/10 "2023-04-28T09:26:51Z")

</div>

> [@kenkoooo-estie](#):
>
> 1. You will receive a session with an `idToken`, `accessTokenExpiresAt`, and other fields. The value of `accessTokenExpiresAt` will be `now + 86400`, as previously described.

Hi @kenkoooo-estie 👋

So when there is no `audience` parameter specified, the _Access Token_ returned from Auth0 is intended for use with the Auth0 ‘[/userinfo](https://auth0.com/docs/api/authentication#get-user-info)’ endpoint only. 🤔 As I recall, you can’t currently set the default expiration for this from the Auth0 Dashboard.

To get an Auth0 _Access Token_ for a specific API you must also specify an `audience`; from the example screenshots shared previously, the `audience` would be the `identifier` associated with the relevant API. You can then set `Token Expiration` to the value desired, and this will be reflected in the _Access Token_ returned. Today, any _Access Token_ generated by Auth0 can be used to call both the (custom) API associated with the designated `audience` _and also_ the Auth0 `/userinfo` endpoint.

Hope that helps 🕶

---

<div class="post-metadata">

**Author:** ![kenkoooo-estie](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@kenkoooo-estie](https://community.auth0.com/u/kenkoooo-estie)\
**Post date:** [May 2, 2023, 5:24am UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/11 "2023-05-02T05:24:50Z")

</div>

Thank you. It is very helpful to know that there is no way to change the expiration time for the Authentication API. Thank you so much, guys.

---

<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:** [May 16, 2023, 5:24am UTC](https://community.auth0.com/t/need-help-changing-token-expiration-time-in-authentication-api-response/104251/12 "2023-05-16T05:24:59Z")

</div>

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