- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
I'm trying to call the https://api.sandbox.paypal.com/v1/oauth2/token to simply have a token.
I'm using php curl.
Here is my code :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sandbox.paypal.com/v1/oauth2/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_USERPWD => $PAYPAL_CLIENT_ID.":".$PAYPAL_SECRET,
CURLOPT_POSTFIELDS => "{\"grant_type\":\"client_credentials\"}",
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Accept-Language: en_US"
),
));
The answer is : {"error":"unsupported_grant_type","error_description":"Grant Type is NULL"}
I checked and I simply use the grant type i've found here : https://developer.paypal.com/docs/api/get-an-access-token-curl/
I'm totally lost with the error, because it's the very beginning of my integration.
Thank you.
Solved! Go to Solution.
- Labels:
-
API
-
Express Checkout
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your attempting to pass the item as a JSON object, which it's not.
It should be :
CURLOPT_POSTFIELDS => "grant_type=client_credentials",
Thanks !
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your attempting to pass the item as a JSON object, which it's not.
It should be :
CURLOPT_POSTFIELDS => "grant_type=client_credentials",
Thanks !
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
I don't know if your answer (for which I thank you !) is the solution, because after implementing it, I have another error : "NSS: client certificate not found (nickname not specified)".
Do you have any idear on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
So if after adding the code I provided you're no longer experiencing the same error, then the code fixed the original issue.
This is confirmed by the new error you're experiencing, as whilst connecting to the sandbox endpoint a matching certificate for the endpoint cannot be found within the NSS store on your local machine.
You will need to add the sandbox certificate (api.sandbox.paypal.com) into your NSS store.
How to add a certificate into a NSS store : https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/tools/NSS_Tools_certutil
PayPal sandbox API certificates download : https://www.paypal.com/us/smarthelp/article/where-can-i-find-ssl-certificates-for-paypal-sandbox-api...
Thanks !
Was my post helpful? If so, please give me a kudos!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please help. Requesting by following giving me `Bad request`.
curl -X POST https://api.sandbox.paypal.com/v1/oauth2/token \ -H 'Authorization: Basic {Your Base64-encoded ClientID:Secret}=' \ -d 'grant_type=authorization_code&code={authorization_code}'
I encrypted `Base64-encoded ClientID:Secret` by btoa. authorization_code is used by capturing from redirect_url
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am also facing the same issue with getting access token at PayPal connect process. See code below:
Request Code:
$curl = curl_init();
$base_token = "{client_id: secret}";
$data = array(
CURLOPT_URL => "https://api.sandbox.paypal.com/v1/oauth2/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'grant_type' => 'authorization_code',
'code' => '{CODE}'
),
CURLOPT_HTTPHEADER => array(
"Authorization: Basic ".$base_token,
),
);
curl_setopt_array($curl,$data );
$response = curl_exec($curl);
curl_close($curl);
Response Code:
stdClass Object ( [name] => Bad Request [debug_id] => 2858088aa4473 [message] => java.lang.IllegalArgumentException [details] => Array ( ) )
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- I want to implement subscription functionality. in REST APIs
- Problems with accent characters when calling Paypal API (v2/invoicing/invoices). in REST APIs
- How can I integrate PayPal to enable direct tipping features between users on a content platform? in REST APIs
- Receiving a PAYMENT.SALE.COMPLETED webhook notification - how can I trace the parent Subscription in REST APIs
- “This payment cannot be processed because there was an error with the capture order API call”. in REST APIs