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 -
-
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.
-
The
access_token
has expired. You will need to generate a newaccess_token
using the magicalrefresh_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.
POST https://api.signeasy.com/oauth2/token
const request = require("request");
const options = {
method: 'POST',
url: 'https://api-ext-dev.getsigneasy.com/oauth/token',
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);
console.log(body);
});
Parameters | Type | Description |
---|---|---|
client_id | string | Required. The same client ID you received when you created the app. |
client_secret | string | Required. The client secret you received when you created the app. |
grant_type | string | Required. Should be refresh_token here. |
refresh_token | string | Required. The refresh_token you obtained earlier from Step 2. |
Updated over 4 years ago