Trying to debug the HubSpot EXPIRED_AUTHENTICATION error? Here's how to fix it.
TABLE OF CONTENTS
Example Response
What Causes the HubSpot expired OAuth token error?
This HubSpot The OAuth token used to make this call expired X minutes ago
error happens when an expired Hubspot OAuth access token is used to make an API call. The current time-to-live for Hubspot access tokens is only 30 minutes, meaning that any requests made to the HubSpot API 30 minutes after the access token is generated will run into this error.
Resolution
When you make a request for Hubspot OAuth tokens with https://api.hubapi.com/oauth/v1/token
, save the access_token
, refresh_token
, and expires_in
parameters from the response. Also, save the timestamp of when you received the response.
Before making an API call, make sure that the HubSpot access token is valid by checking if the current timestamp < timestamp + expires_in
.
If the current timestamp is greater, request a new access token with the refresh token you got previously.
Fully managed HubSpot auth
If you want to completely offload dealing with HubSpot’s auth errors when building a native HubSpot integration for your application, you can use Paragon.
Access/refresh token management is handled by Paragon's authentication layer for any 3rd party SaaS integration you need to build, so you can focus on implementing your integration logic instead of fixing errors such as the HubSpot The OAuth token used to make this call expired X minutes ago
error.
With a single paragon.connect('hubspot');
call, you can embed a modal where your users can configure and authenticate into their HubSpot accounts - the Paragon SDK will handle the entire HubSpot auth flow and refresh tokens as necessary so you don’t need to.
Here’s an example of our customer TL;DV that relies on Paragon to handle the entire OAuth flow for their application’s HubSpot integration.
To see if Paragon can help streamline your product's native integration development process, check out our documentation and sign up for a free trial.
If you want to avoid dealing with auth errors again while building a native HubSpot (or any other) integration for your app, try out Paragon.