3 weeks ago
- last edited
3 weeks ago
by BérangèreL
Member
Trouble Getting Refresh Token
SOLVE
Hello,
I'm having troubles getting the refresh token for my API integration. On the https://developers.hubspot.com/docs/api-reference/auth-oauth-v1/guide page, it says all I have to do is execute the curl script below, replacing the values provided in the sample with those specific to my application.
When I replace the values and execute, I get the error response below. I am pretty sure the issue is with the code parameter.
{"status":"BAD_AUTH_CODE","message":"missing or unknown auth code","correlationId":"REMOVED"}
The documentation says:
After a user authorizes your app and installs it into their account, the redirect URL will be appended with a code value, which you can use to generate an access token and a refresh token.
However, that isn't quite what happened. I got redirected to a page without a query string parameter. To get the code parameter, I had to open up the Chrome dev tools and snag it from the network activity log. I fear the code may not be the correct one i'm looking for.
Hi @embkca and welcome, we are delighted to have you here! 🤗
Thanks for your detailed post on the HubSpot Community!
The error {"status":"BAD_AUTH_CODE","message":"missing or unknown auth code"} typically means the authorization code is invalid or expired.
A few things to check:
- The code must be captured from the redirect URL immediately after user authorization; it’s only valid for a short time and can be used once. - Make sure the redirect_uri in your token request matches exactly with the one used in your app’s authorization step.