APIs & Integrations

Not applicable

Facing Problem while integrating Trust pilot API to php code

Hello
My need is to generate unqiue link for the customers of trustpilot widget .For that i need to have access token .I tried all possible ways but facing same error

{“reason”:“Unknown grant_type”} "

Below is my code for the same

$data = array(
GRANT_TYPE => GRANT_TYPE_VALUE,
TRUSTPILOT_USERNAME => TRUSTPILOT_USERNAME_VALUE,
TRUSTPILOT_PASSWORD => TRUSTPILOT_PASSWORD_VALUE,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,“https://api.trustpilot.com/v1/oauth/oauth-business-users-for-applications/accesstoken”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Authorization: Basic base64 encoded apikey:secretkey’,
‘Content-Type: application/json’
));
$server_output = curl_exec($ch);
curl_close($ch);
var_dump($server_output);

Thanks in advance

0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Facing Problem while integrating Trust pilot API to php code

Hi @Hetal1311,

It doesn’t look like this code is making requests to the HubSpot APIs. I’m not familiar with trust pilot, but based on their documentation it would appear that you’ll need to set the grant_type to password in order to use the username/password authentication.

https://developers.trustpilot.com/authentication#password

0 Upvotes