# Expired token received for JSON Web Token validation

**URL:** <https://community.auth0.com/t/expired-token-received-for-json-web-token-validation/134054>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [May 14, 2024, 2:46am UTC](https://community.auth0.com/t/expired-token-received-for-json-web-token-validation/134054 "2024-05-14T02:46:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nakuruhope](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nakuruhope/32/57093_2.png) [@nakuruhope](https://community.auth0.com/u/nakuruhope)\
**Post date:** [May 14, 2024, 2:46am UTC](https://community.auth0.com/t/expired-token-received-for-json-web-token-validation/134054/1 "2024-05-14T02:46:29Z")

</div>

Using the offiical auth0 nodeJS SDK.

Before we make any management API request, we use the auth0 provided code snippet to get a machine-to-machine access token and new client.

```auto
const res = await fetch(`${process.env.AUTH0_ISSUER_BASE_URL}/oauth/token`, {
    method: 'post',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({
      client_id: process.env.AUTH0_CLIENT_ID,
      client_secret: process.env.AUTH0_CLIENT_SECRET,
      audience: `${process.env.AUTH0_ISSUER_BASE_URL}/api/v2/`,
      grant_type: 'client_credentials'
    })
  });

  const body = await res.json();

  console.log(body);

  return new ManagementClient({
    token: body.access_token,
    domain: `${process.env.AUTH0_TENANT}.au.auth0.com`
  }); 

```

We then try to retrieve user information:

```auto
await auth0Client.users.get({ id: auth0Id });

```

Sometimes this returns us an error message “Expired token received for JSON Web Token validation”. Not sure what else we can do here. Any ideas?

---

<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 15, 2024, 10:43pm UTC](https://community.auth0.com/t/expired-token-received-for-json-web-token-validation/134054/3 "2024-05-15T22:43:44Z")

</div>

Hey there @nakuruhope welcome to the community!

> [@nakuruhope](#):
>
> Sometimes this returns us an error message “Expired token received for JSON Web Token validation”. Not sure what else we can do here. Any ideas?

Sometimes as in it may throw that error and then proceed to work again? Management API access tokens do have a relatively [short lifetime](https://auth0.com/docs/secure/tokens/access-tokens/management-api-access-tokens#token-lifetime).

---

<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:** [June 28, 2024, 8:57pm UTC](https://community.auth0.com/t/expired-token-received-for-json-web-token-validation/134054/4 "2024-06-28T20:57:39Z")

</div>

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