I am truly stumped here; trying to use the PayPal REST api and cannot even get the access token. When using CURL (example), the token is created fine so I know the Client ID and Secret are OK.
When I use the code below with the PHP libraries, I get null's for access token in JSON Response.
require_once('/home/admin/vendor/autoload.php');
$host = 'https://api.sandbox.paypal.com';
$clientId = <CLIENT_ID>;
$clientSecret = <CLIENT_SECRET>;
use PayPal\Auth\OAuthTokenCredential;
$sdkConfig = array(
"mode" => "sandbox"
);
$cred = new OAuthTokenCredential(
$clientId,
$clientSecret,
$sdkConfig
);
var_dump($cred);
var_dump JSON Response: "accessToken":"PayPal\Auth\OAuthTokenCredential":private]=> NULL
From looking at the SDK code, the
OAuthTokenCredential
constructor method doesn't take a$config
parameter but thegetAccessToken()
method does.Here are the methods from the
OAuthTokenCredential
class code:The following should get an access token for you: