I have built a private API that receive messages from chat from Hubspot.
I have 2 applications sending messages to my API. Both were working fine but since a week, one app crash due to an issue with the refresh token.
When I receive a message in my API, I get a HubspotLink object which contains refreshToken=eu1-ad...b2, tokenExpire=2024-06-27T15:10:14.805Z
My working application, if the refresh token is expired go through this function:
and then I have a working access token then everything goes well
My failing application has exactly the same behavior until it reach the function to get a new refresh token (see screenshot). There, it goes in the "If" and gives me "Error 400 while getting token {"status":"BAD_REFRESH_TOKEN","message":"missing or invalid refresh token","correlationId":"663b9397-c63b-4809-ba4f-0599049db23b"}"
Why the refresh token is now considered as invalid ? Is there something i'm supposed to do in hubspot settings because I see nothing I can do in the code.
About the refresh token issue, It's already what we're doing but somehow, we still have "Error 400 while getting token {"status":"BAD_REFRESH_TOKEN","message":"missing or invalid refresh token","correlationId":"663b9397-c63b-4809-ba4f-0599049db23b"}"
Somehow, it seems that our application send corrupted token or something consider as invalid by the API.
Is it possible that this is a result of your app being uninstalled? To test this, I'd suggest using the GET HubSpot OAuth Refresh Token endpoint. For example:
GET https://api.hubapi.com/oauth/v1/refresh-tokens/YOUR_REFRESH_TOKEN
If you receive a 404 Not Found error response, this means you've made a mistake in your capture/storage/retrieval of the given refresh token, or the refresh token is no longer valid because the app has been uninstalled from the given HubSpot Portal.
I hope that proves helpful. Please let me know if you have any follow-up questions.
All the best,
Zach
--
Zach Klein HubSpot Integrations & App Developer Meanjin / Brisbane, Australia
It's already what I'm doing but somehow, I have "Error 400 while getting token {"status":"BAD_REFRESH_TOKEN","message":"missing or invalid refresh token","correlationId":"663b9397-c63b-4809-ba4f-0599049db23b"}"
Somehow, it seems that my application send corrupted token or something consider as invalid by the API