HubSpot OAuth BAD_REFRESH_TOKEN — What it means & how to fix it
Blog post from Nango
Encountering a "BAD_REFRESH_TOKEN" error when integrating with HubSpot's APIs using OAuth indicates a missing or invalid refresh token, requiring detection and resolution to maintain smooth functionality. This error can occur due to user actions such as uninstalling the app or manually revoking access, surpassing token limits, token expiration due to inactivity, scope changes, or mismatches in client credentials. Fixing the issue involves asking users to re-authenticate and ensuring correct client credentials are used, while preventing future occurrences can be achieved by regularly refreshing tokens, discarding stale ones, and monitoring for spikes in errors. Employing engineering practices such as setting webhooks for app uninstallation and implementing proper error handling can mitigate disruptions. Additionally, using tools like Nango can automate OAuth token management, allowing developers to focus on product features without worrying about token lifecycle complexities.