These docs are for v2.1. Click to read the latest docs for v3.

Refreshing Access Tokens

What do you do when your access tokens expire?

As you start making API calls using the access_token you now have, you will soon encounter a 401 Unauthorized responses which can usually mean a couple of things -

  1. You are trying to use an API that the user has not authorized your app to use. Check the scopes you are asking your users to authorize your app for.

  2. The access_token has expired. You will need to generate a new access_token using the magical refresh_token that you encountered earlier in Step 2.

Regenerate access tokens using refresh token

To generate or create a new access token, make a POST call with parameters similar to the ones you used in Step 2.

const request = require("request");

const options = {
  method: 'POST',
  url: '',
  json: true,
  formData: {
    client_id: <CLIENT_ID>,
    client_secret: <CLIENT_SECRET>,
    grant_type: 'refresh_token',
    refresh_token: <REFRESH_TOKEN>

request(options, function (error, response, body) {
  if (error) throw new Error(error);

client_idstringRequired. The same client ID you received when you created the app.
client_secretstringRequired. The client secret you received when you created the app.
grant_typestringRequired. Should be refresh_token here.
refresh_tokenstringRequired. The refresh_token you obtained earlier from Step 2.