What Causes the HubSpot expired OAuth token error?
This HubSpot [.inline-code-highlight]The OAuth token used to make this call expired X minutes ago[.inline-code-highlight] 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.
When you make a request for Hubspot OAuth tokens with [.inline-code-highlight]https://api.hubapi.com/oauth/v1/token[.inline-code-highlight], save the [.inline-code-highlight]access_token[.inline-code-highlight], [.inline-code-highlight]refresh_token[.inline-code-highlight], and [.inline-code-highlight]expires_in[.inline-code-highlight] 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 + [.inline-code-highlight]expires_in[.inline-code-highlight].
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.
With a single [.inline-code-highlight]paragon.connect('hubspot');[.inline-code-highlight] 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 QuickBooks (or any other) integration for your app, try out 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 Salesforce invalid_grant - expired access/refresh tokens error.
With a single [.inline-code-highlight]paragon.connect('salesforce');[.inline-code-highlight] call, the Paragon SDK will handle the entire authorization flow and refreshes tokens on behalf of your customers.