Chris Harland
Chris Harland

Reputation: 476

Paypal API Returns Access Token as Null

I have installed the Paypal PHP SDK and am having trouble getting a access token in Sandbox mode.

$sdkConfig = array(
    "mode" => "sandbox"
);

// new OAuthTokenCredential(ClientID, Secret, sdkConfig)
$cred =  new OAuthTokenCredential("$clientID","$secret", $sdkConfig);

The $cred, when returned, only has the client, secret and logging manager populated, everything else is null.

When stepping through the OAuthTokenCredential class it only runs through as far as the initial function. None of the accesstoken functions run.

I'm assuming that the SDK is okay as other people are presumably using it, so I'm guessing that there is a fairly simple solution.

Upvotes: 1

Views: 999

Answers (1)

Chris Harland
Chris Harland

Reputation: 476

It isn't documented anywhere, but I've found that adding this directly after the above code works perfectly.

$cred->accessToken = $cred->getAccessToken($sdkConfig);

Not sure why it isn't documented, but this now works for me.

Upvotes: 2

Related Questions