BAD_REFRESH_TOKEN while trying to refresh token

Hey:

I am trying to refresh a token, but unfortunately, I receive status 400 with:

{

“status”: “BAD_REFRESH_TOKEN”,

“message”: “missing or invalid refresh token”,

“correlationId”: “13aa419f-f7c7-4f2a-85e3-cd837c669576”

}

In request I send following params:

refreh_token: TOKEN
client_secret: ID
client_id: SECRET
grant_type:refresh_token

I have header set to: application/x-www-form-urlencoded;charset=utf-8

How can I successfully refresh a token?

Hey @mateuszg

Can you please post the post request script that you have written for the refreshing the access token?

Thanks!

Hi @himanshurauthan :

 let refreshTokenResult;

 const requestBody = {
 grant_type: 'refresh_token',
 client_id: clientId,
 client_secret: clientSecret,
 refresh_token: account.remoteConnection.hubspot.accessToken,
 };

 try {
 refreshTokenResult = await rp({
 method: 'post',
 url: 'https://api.hubapi.com/oauth/v1/token',
 headers: {
 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
 },
 body: querystring.stringify(requestBody),
 });
 } catch (error) {
 global.logger.error(error);
 throw new Error('Cannot refresh HubSpot access token');
 }

Solved it. We were using access_token instead of refresh token to refreshing

I just figured out that if there are any new line or invalid characters in the refresh token it gives the error message BAD_REFRESH_TOKEN