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.
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
@zach_threadint
Hope you’ll be able to understand our issue :
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.
Really need your help please.
Regards.
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:
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.
BAD_REFRESH_TOKEN in HubSpot is usually one of three things: (1) the user uninstalled/reinstalled the app (token revoked) (2) you’re refreshing in parallel (race condition across workers/instances) (3) you’re using a token issued to a different app/env (mismatch/store mix-up).
Also, using something like Nango would help you avoid these issues as Nango takes care of the token related chores like access/refresh token rotation, conucrrancy issues, secure storage for all your connections.