Oct 7, 2020 10:48 AM - edited Oct 7, 2020 11:28 AM
Below PHP code to exchange authorization code for token, Please help on this:
$code = $_GET['code'];
$url = "https://api.hubapi.com/oauth/v1/token";
$post_fields = array('form' =>
array(
'grant_type' => 'authorization_code',
'client_id' => CLIENT_ID,
'client_secret' => CLIENT_SECRET,
'redirect_uri' => REDIRECT_URI,
'code' => $code
)
);
$post_fields = json_encode($post_fields);
$headers = array(
"Accept:application/json",
"Content-Type:application/json",
);
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_fields );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_HEADER, true);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
$page = curl_exec($ch);
$info = curl_getinfo($ch);
var_dump($page);
var_dump($info);
Oct 7, 2020 4:37 PM
Hi @Drace ,
Wanted to point you to this post originally asked by @michaelbarley which includes some possibly helpful resources.
Hope you get this resolved!