In my Dev environment, I can correctly use the Rest API to the sandbox site:
$sdkConfig = array(
"mode" => 'sandbox'
);
$cred = new OAuthTokenCredential(
$SANDBOX_clientId,
$SANDBOX_clientSecret
);
$access_token = $cred->getAccessToken($sdkConfig);
When using the same code with Live Keys and a verified Live account:
$sdkConfig = array(
"mode" => 'live'
);
$cred = new OAuthTokenCredential(
$LIVE_clientId,
$LIVE_clientSecret
);
$access_token = $cred->getAccessToken($sdkConfig);
I get this error: Http response code 401 when accessing https://api.sandbox.paypal.com/v1/oauth2/token
How does the PayPal REST API know which endpoint to access?
I am not specifying the endpoint in the sandbox or live calls and am not using a bootstrap or ini file. The account is verified and approved.
The best way I would recommend is to create an
ApiContext
object similar to shown at https://gist.github.com/jaypatel512/a2b037ab5ddc51fa7280