I'm new to this community so I hope I'm posting on the correct board. I'm trying to learn how to do the REST Api. I'm writing it all it PHP. I have this code trying to get an Access Token from the Oauth2 thing-a-ma-jiggy... :)... This is the code I'm using but it returns an error. What am I doing wrong? $clientID = '<xxxxxxxxxxxx>'; $secret = '<xxxxxxxxxxxx>'; $token = base64_encode($clientID.':'.$secret); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api-m.sandbox.paypal.com/v1/oauth2/token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=client_credentials"); curl_setopt($ch, CURLOPT_USERPWD, base64_encode('<'.$clientID.'>' . ':' . '<'.$secret.'>')); $headers = array(); $headers[] = 'Content-Type: application/x-www-form-urlencoded'; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close($ch); echo '<br><br>Dump oauth2: $response:<br>'; var_dump($result); I have been trying many different set-ups. The other day, I was able to get it to work, but it is not working now. I had used json_encode() on the return string and I had access to the scope, the id... everything. But now it is not working. I am getting this error: {"error":"invalid_client","error_description":"Client Authentication failed"} Any help would be appreciated. Thank You.
... View more