unsupported_grant_type when trying to POST request to PayPal Connect from Laravel

sallminrexha
Contributor
Contributor

Hi all, 

 

I have an issue where after sending post request to PayPal connect I get the error of unsupported_grant_type.

My code:

$client = new \GuzzleHttp\Client();
$clientId = "MY_CLIENT_ID";
$clientSecret = "MY_CLIENT_SECRET";
$authorizationString = base64_encode($clientId . ':' . $clientSecret);
$res = $client->request('POST', 'https://api.sandbox.paypal.com/v1/oauth2/token', ['headers' => [
'Authorization' => 'Basic ' . $authorizationString,
],
'form_params' => [
'grant_type ' => 'authorization_code',
'code ' => $data['code']
]
]);
Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

sallminrexha
Contributor
Contributor

I managed to fix this one only by marking grant_type with double braces "grant_type" nothing else

View solution in original post

Login to Me Too
2 REPLIES 2

anemr1r1
New Community Member

i have any problem !

Login to Me Too
Solved

sallminrexha
Contributor
Contributor

I managed to fix this one only by marking grant_type with double braces "grant_type" nothing else

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.