Get OAuth access and refresh tokens ensuring your ability to securely perform CRUD actions with HubSpot APIs.
client_id
, redirect_uri
, and scopes
as query parameters. You may also include optional_scopes
and state
, if needed.
After a user authorizes your app and installs it into their account, the redirect URL will be appended with a code
value, which you can use to generate an access token and a refresh token. The access token will be used to authenticate requests that your app makes, while the refresh token will be used to get a new access token when the current one expires.
Learn more about initiating OAuth for your app.
POST
request to /oauth/v1/token
. In the request body, you’ll specify various auth parameters, such as client_id
and client_secret
, along with the code
passed back through the redirect URL.
After a user authorizes your app, the redirect URL will be appended with a code
value. Using this code, you’ll generate the initial access token and refresh token. Access tokens are short-lived, and you can check the expires_in
parameter when generating an access token to determine its lifetime (in seconds).
For example, your request may look similar to the following:
Parameter | Type | Description |
---|---|---|
grant_type | String | Must be authorization_code for the request to generate initial access and refresh tokens. |
code | String | The code returned in the redirect URL after the user installs the app. |
redirect_uri | String | The app’s set redirect URL. |
client_id | String | The app’s client ID. |
client_secret | String | The app’s client secret. |
expires_in
field specifies how long the access token will last (in seconds).
POST
request to /oauth/v1/token
. In the request body, you’ll specify the grant_type
, client_id
, client_secret
, and refresh_token
.
Parameter | Type | Description |
---|---|---|
grant_type | String | Must be refresh_token for the request to generate new access tokens from the refresh token. |
refresh_token | String | The refresh token value. |
client_id | String | The app’s client ID. |
client_secret | String | The app’s client secret. |
GET
request to /oauth/v1/access-tokens/{token}
.
You’ll receive a response containing information about the user’s access token and their HubSpot account.
DELETE
request to /oauth/v1/refresh-tokens/{token}
. This will only delete the refresh token. Access tokens generated with the refresh token will not be deleted. Additionally, this will not uninstall the application from HubSpot accounts or inhibit data syncing between the app and account.