How to check access_token is expired?

what is best way to check access_token is expired using JavaScript ?

Hey there @sajan welcome to the community!

Each access token will have an exp (expiration) claim which is a Unix timestamp, here’s a sample access token.

You’ll most likely want to use a library listed here to decode an access token in order to inspect the exp claim.

Hope this helps!

3 Likes

thanks for your response. which property need to consider as token expire value access_token.exp or expires_in ?

{
  "iss": "https://my-domain.auth0.com/",
  "sub": "auth0|123456",
  "aud": [
    "https://example.com/health-api",
    "https://my-domain.auth0.com/userinfo"
  ],
  "azp": "my_client_id",
  "exp": 1311281970,
  "iat": 1311280970,
  "scope": "openid profile read:patients read:admin"
}
{
    "access_token": "",
    "scope": "",
    "expires_in": 9600,
    "token_type": "Bearer"
}

No problem, happy to help!

It really depends on what you’re looking for - exp is the timestamp for the expiration date where as expires_in is the number of seconds to expiration.

1 Like

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