Note that there are some explanatory texts on larger screens.

plurals
  1. POPayPal API: Exception: 401 when accessing https://api.sandbox.paypal.com/v1/oauth2/token
    primarykey
    data
    text
    <p>The specific <code>401</code> error message I get is:</p> <p><code>"error":"invalid_client","error_description":"The client credentials are invalid"}"</code></p> <p>This error isn't listed anywhere in the PayPal documentation. I am certain I am using the test credentials and using the correct sandbox endpoint. The error occurs when I attempt to get an access token. </p> <p>This is the class where the access token is retrieved:</p> <pre><code>private function _generateAccessToken($config) { $base64ClientID = base64_encode($this-&gt;clientId . ":" . $this-&gt;clientSecret); $headers = array( "User-Agent" =&gt; PPUserAgent::getValue(RestHandler::$sdkName, RestHandler::$sdkVersion), "Authorization" =&gt; "Basic " . $base64ClientID, "Accept" =&gt; "*/*" ); $httpConfiguration = $this-&gt;getOAuthHttpConfiguration($config); $httpConfiguration-&gt;setHeaders($headers); $connection = PPConnectionManager::getInstance()-&gt;getConnection($httpConfiguration, $config); //print_r($connection); die; $res = $connection-&gt;execute("grant_type=client_credentials"); $jsonResponse = json_decode($res, true); if($jsonResponse == NULL || !isset($jsonResponse["access_token"]) || !isset($jsonResponse["expires_in"]) ) { $this-&gt;accessToken = NULL; $this-&gt;tokenExpiresIn = NULL; $this-&gt;logger-&gt;warning("Could not generate new Access token. Invalid response from server: " . $jsonResponse); } else { $this-&gt;accessToken = $jsonResponse["access_token"]; $this-&gt;tokenExpiresIn = $jsonResponse["expires_in"]; } $this-&gt;tokenCreateTime = time(); return $this-&gt;accessToken; } </code></pre> <p>This is the <code>$connection</code> variable I have when I <code>print_r</code> (I removed the authorization string):</p> <pre><code>PayPal\Core\PPHttpConnection Object( [httpConfig:PayPal\Core\PPHttpConnection:private] =&gt; PayPal\Core\PPHttpConfig Object ( [headers:PayPal\Core\PPHttpConfig:private] =&gt; Array ( [User- Agent] =&gt; PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.4.21;bit=64;os=Linux_2.6.18- 308.16.1.el5;machine=x86_64;openssl=0.9.8e-fips-rhel5;curl=7.24.0) [Authorization] =&gt; Basic REMOVED AUTHORIZATION STRING == [Accept] =&gt; */* ) [curlOptions:PayPal\Core\PPHttpConfig:private] =&gt; Array ( [32] =&gt; 3 [78] =&gt; 30 [19913] =&gt; 1 [13] =&gt; 60 [10018] =&gt; PayPal-PHP-SDK [10023] =&gt; Array ( ) [81] =&gt; 2 [64] =&gt; 1 ) [url:PayPal\Core\PPHttpConfig:private] =&gt; https://api.sandbox.paypal.com/v1/oauth2/token [method:PayPal\Core\PPHttpConfig:private] =&gt; POST [retryCount:PayPal\Core\PPHttpConfig:private] =&gt; 1 ) [logger:PayPal\Core\PPHttpConnection:private] =&gt; PayPal\Core\PPLoggingManager Object ( [loggerName:PayPal\Core\PPLoggingManager:private] =&gt; PayPal\Core\PPHttpConnection [isLoggingEnabled:PayPal\Core\PPLoggingManager:private] =&gt; 1 [loggingLevel:PayPal\Core\PPLoggingManager:private] =&gt; 3 [loggerFile:PayPal\Core\PPLoggingManager:private] =&gt; PayPal.log )) </code></pre> <p>As far I can tell, I have correct credentials, correct endpoint, not sure what else it could be?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload