APIs & Integrations

RMelliti
Member

Refresh Token issue

SOLVE

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:

Capture d’écran 2024-06-27 à 16.16.15.png

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.

 

thanks !

0 Upvotes
1 Accepted solution
zach_threadint
Solution
Guide

Refresh Token issue

SOLVE

Hi @Guyomeo 👋

 

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



Say g'day


If my post helped answer your query, please consider marking it as a solution.


View solution in original post

0 Upvotes
4 Replies 4
Guyomeo
Member

Refresh Token issue

SOLVE

HI @himanshurauthan

@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.



0 Upvotes
zach_threadint
Solution
Guide

Refresh Token issue

SOLVE

Hi @Guyomeo 👋

 

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



Say g'day


If my post helped answer your query, please consider marking it as a solution.


0 Upvotes
AddaxLab
Member

Refresh Token issue

SOLVE

It looks like the refresh token has been got incorrectly.

As soon as the access token expires, call the refresh token function it will update the refresh token and return a new access token.
 
Please see the code attached:
02974_1-1719511091183.png

Best regards,
02974_0-1719510898077.png
0 Upvotes
RMelliti
Member

Refresh Token issue

SOLVE

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

0 Upvotes