When should I renew my oAuth2 access token?

The access token returned by the Get an Oauth2 access token has an expiration time of 1 month. If the access token is either expired or revoked you will get the following 401 error:

  "error": "INVALID_GRANT",
  "message": "The access token expired"

As soon as you get this error you need to Get an oAuth2 access token again using your client id and client secret.
More information about the oAuth2 protocol: How does OAuth2 authentication protocol work?

We are also providing several client libraries (PHP, Ruby, Javascript, Java…) that handle the oAuth part for you. We recommend you to use them and open a pull request if you need to as we are reactive to any PR.

Please see here the precautions for using a JWT token.