# Change expiration Time of access token

**URL:** <https://community.auth0.com/t/change-expiration-time-of-access-token/125726>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [January 25, 2024, 6:47pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726 "2024-01-25T18:47:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![me1k](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/me1k/32/54262_2.png) [@me1k](https://community.auth0.com/u/me1k)\
**Post date:** [January 25, 2024, 6:47pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/1 "2024-01-25T18:47:20Z")

</div>

Hi,

i try to decrease the expiration time from my access\_token, but when i set a new value in my API Details under Auth0 Management Api → Token Settings → Token Expiration → 30000ms

In my session object under accessTokenExpiresAt the value is still a different. In my case 1706293978ms…

What can i do to change this expiration?

I’m on a nextjs project an use the @auth0/nextjs-auth0 package.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [January 25, 2024, 7:39pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/3 "2024-01-25T19:39:35Z")

</div>

Hi @me1k,

Welcome to the Auth0 Community!

It looks like you have [changed the access token expiration time](https://community.auth0.com/t/change-access-token-expiration-time/122560) correctly. However, let me clarify that the token expiration is in seconds instead of milliseconds. See below:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/7/1/71e805686736ac2107cf5fee9a9c5032dc5cd5a0.png)

Additionally, the value `1706293978` you shared is the expiration time in seconds since Unix epoch. Using [jwt.io](http://jwt.io) to decode my token, here is an example:

![image](https://global.discourse-cdn.com/auth0/original/3X/4/e/4e9818a369c0262aed9c66adf4c1341f084eacc0.png)

Hovering over the time gives you the GMT date and time: ![image](https://global.discourse-cdn.com/auth0/original/3X/a/0/a07a8196efa1922884b77e174d08ce56a35ecd55.png)

To verify that your expiration time is correct, you can look at the `exp` and `iat` claim of your access token.

Then you can perform the following calculation:

- Token expiration (in seconds) = `exp` (Expiration time in seconds) - `iat` (Issued at in seconds)

The token expiration time should match the value you set in your token settings.

Let me know how this goes for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![me1k](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/me1k/32/54262_2.png) [@me1k](https://community.auth0.com/u/me1k)\
**Post date:** [February 5, 2024, 1:04pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/5 "2024-02-05T13:04:04Z")

</div>

Hi @rueben.tiow , thank you for your reply!

This works for me 🙂

One more question … How do i get an refresh token? Do i need to request it seperately?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 5, 2024, 5:56pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/6 "2024-02-05T17:56:07Z")

</div>

Hi @me1k,

Thanks for the update. Good to hear it’s working!

To get a refresh token, you will need to pass the `offline_access` scope in your login request.

See our [Get Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens/get-refresh-tokens) documentation.

Cheers,  
Rueben

---

<div class="post-metadata">

**Author:** ![me1k](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/me1k/32/54262_2.png) [@me1k](https://community.auth0.com/u/me1k)\
**Post date:** [February 5, 2024, 6:45pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/7 "2024-02-05T18:45:07Z")

</div>

Thank you for your reply.

I already checked this documentation. But honestly don’t get it. Maybe bc i’m also quite new to next.js.

I use the `@auth0/nextjs-auth0` package and createt this route:

```auto
import { handleAuth } from '@auth0/nextjs-auth0';

export const GET = handleAuth();

```

so login and logout works quite straight forward with api/auth/login or logout. But the documentation says i need to use /authorize… But the

```auto
handleAuth

```

from @auth0/nextjs-auth0 doesn’t seem to bring this when i type /api/auth/authorize in the url

do you have a hint maybe for me? Would appreciate.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 5, 2024, 8:41pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/8 "2024-02-05T20:41:36Z")

</div>

Hi @me1k,

Essentially, you need to include the `offline_access` scope in your configuration (or `AUTH0_SCOPE`) within the `.env.local` file.

(Reference:[ConfigParameters | @auth0/nextjs-auth0](https://auth0.github.io/nextjs-auth0/types/config.ConfigParameters.html#:~:text=AUTH0_SCOPE%3A%20See%20BaseConfig.authorizationParams.))

Also, let me add that the `/authorize` endpoint is called when you use the login handler in Auth0 Next.js SDK. You can verify this by checking the network activity.

I hope this helps!

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![me1k](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/me1k/32/54262_2.png) [@me1k](https://community.auth0.com/u/me1k)\
**Post date:** [February 6, 2024, 10:50am UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/9 "2024-02-06T10:50:08Z")

</div>

Hi @rueben.tiow,

i’m sorry but i cannot find the solution.

I tried to put the `offline_access` to the `options` of `handleLogin`. But i cannot find the attribute within `authorizationOptions` where to put it in? when i put it to `scope` i get the error, that `scope` only can have `openid`. And in the documentation [AuthorizationParams | @auth0/nextjs-auth0](https://auth0.github.io/nextjs-auth0/interfaces/handlers_login.AuthorizationParams.html) i cannot find anything about `offline_access`. And when i put it to the `.env` like so: `AUTH0\_SCOPE = ‘offline\_access’ i get the following error:

```auto
 ⨯ node_modules/@auth0/nextjs-auth0/dist/auth0-session/get-config.js (197:14) @ get
 ⨯ TypeError: "authorizationParams.scope" with value "offline_access" fails to match the contains openid pattern
    at Page (./src/app/page.tsx:19:90)
    at stringify (<anonymous>)
digest: "2392272747"

```

Edit: Well … just adding `openid` as well to the scope did it and now i get a refreshToken.  
`scope: 'openid offline_access`

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 7, 2024, 6:03pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/10 "2024-02-07T18:03:48Z")

</div>

Hi @me1k,

Thanks for the update. Good to hear that it’s working now!

Feel free to reach out to us again if you have any additional questions.

Thanks,  
Rueben

---

<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:** [February 21, 2024, 6:04pm UTC](https://community.auth0.com/t/change-expiration-time-of-access-token/125726/11 "2024-02-21T18:04:19Z")

</div>

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