Unable to get access and refresh token with auth code
Hi!
I am trying to connect my Hubspot App.
We have received the auth code needed to exchange it for access and refresh token. However, there was a problem with our server, so we couldn't send the request for the tokens in less than 10 minutes (which I've seen it's the expiration of the code), so we now get the following error:
"status":"EXPIRED_AUTH_CODE",
"message":"auth code has expired".
How can we request a new auth code to be able to use our access and refresh tokens?
It doesn't work when we try agian through the URL form the first time :
In step 1, you need to send request to HS for auth request with your APP client ID, scopes and redirect URI. In response, a code will be returned.
In step 2, the previously obtained code has to be used for requesting access and refresh tokens. The code remain valids for few seconds and can not be reused.
$data = array( 'grant_type' => 'authorization_code', 'client_id' => $hapikey, 'client_secret' => $hseckey, 'code' => $_GET['code'], 'redirect_uri' => example.com, ); $_GET['code'] is the code received in step1
As the HubSpot access token remains valid for 6 hours only so it is required to refresh the access token timely or better is to check with expiry timestamp of access token. For this, step 3 is needed.