Ryan Dorn
Ryan Dorn

Reputation: 797

Hubspot Webhooks: Redirect Auth & BAD_GRANT_TYPE Message

I'm trying to add a custom app in Hubspot. I'm using PHP. I have:

Upvotes: 2

Views: 740

Answers (1)

Tumtex
Tumtex

Reputation: 61

I had the same error response and it seemed that this is an encoding issue.

I debugged with Postman and found out that the following code works:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.hubapi.com/oauth/v1/token",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "grant_type=authorization_code&code=string&redirect_uri=string&client_id=string&client_secret=string",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/x-www-form-urlencoded",
    "Cookie: __cfduid=someidfrompostman"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Upvotes: 1

Related Questions