I'm trying to add a custom app in Hubspot. I'm using PHP. I have:
- A Hubspot app
- A working webhook URL

A redirect URL with the following code
$url = 'https://api.hubapi.com/oauth/v1/token'; $code = $_GET['code']; // Getting code parameter from redirect URL //echo $code; $fields = array(); $fields['grant_type'] = 'authorization_code'; // Have also tried 'refresh_token' - same result $fields['client_id'] = '{CLIENT_ID}'; $fields['client_secret'] = '{CLIENT_SECRET}'; $fields['redirect_uri'] = '{REDIRECT_URI}'; $fields['code'] = trim($code); //$fields['refresh_token'] = trim($code); // Have also tried 'refresh_token' - same result $request_type = 'POST'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', $headers)); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, POST); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); if($fields){ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $return = curl_exec($ch); curl_close($ch); echo var_dump ($return);My understanding is that Hubspot will use the 'code' parameter passed to the on the "authorization" URL to validate the authorization. However, I keep getting this error:
string(171) "{"status":"BAD_GRANT_TYPE","message":"missing or unknown grant type","correlationId":"f0508752-24bc-40e4-b0bc-51e358459653","requestId":"96044613d4e4a5aab7356fab04001e5c"}"