PayPal REST Api error: response 401 PPConnectionException

I'm using the PHP PayPal REST API sandbox and getting errors when I do my $payment->create( $apiContext );

My Error log reads as:

    PHP Fatal error:  Uncaught exception 'PayPal\\Exception\\PPConnectionException' with message 

'Got Http response code 401 when accessing https://api.paypal.com/v1/oauth2/token. 
    Retried 0 times.' in /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php:99\nStack trace:\n

#0 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Auth/OAuthTokenCredential.php(96): 
    PayPal\\Core\\PPHttpConnection->execute('grant_type=clie...')\n

#1 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Auth/OAuthTokenCredential.php(76): 
    PayPal\\Auth\\OAuthTokenCredential->_generateAccessToken(Array)\n

#2 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/Rest/RestHandler.php(56): PayPal\\Auth\\OAuthTokenCredential->getAccessToken(Array)\n

#3 /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Transport/PPRestCall.php(41): 
    PayPal\\Rest\\RestHandler->handle(Object(PayPal\\Core\\PPHttpConfig), '{"intent":"sale...', Array)\n

#4 /usr/local/web/servers/domain/guts/paypal_api/lib/PayPal/A in 
    /usr/local/web/servers/domain/guts/paypal_api/vendor/paypal/sdk-core-php/lib/PayPal/Core/PPHttpConnection.php on line 99, 
    referer: http://domain.com/products/basket/verify/

my PayPal.log file shows:

PayPal\Core\PPHttpConnection: Connecting to https://api.paypal.com/v1/oauth2/token
PayPal\Core\PPHttpConnection: Payload grant_type=client_credentials
PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.3.3;bit=64;os=Linux_2.6.18-348.6.1.el5;machine=x86_64;openssl=0.9.8e-fips-rhel5;curl=7.15.5)
PayPal\Core\PPHttpConnection: Adding header Authorization: Basic QVpteVVCQ3VfdDhlb3QxcGx0UksyUG56Y3NhcXpOeXNIMlNDLXBDbTlUNGVGNDE3OFd1cFBFRmhkTVpnOkVGZ3g4UkNCZUppSkw3NW1JV1FDRFROTVVsanFOLW1fdlFuM3owMzZOZ3EwTUp3RVFwRkNlV0Z0dWhaag==
PayPal\Core\PPHttpConnection: Adding header Accept: */*

I've tried test cc numbers, cc numbers set up on paypal's sandbox site. I've tried using the credentials in the demo app provided in rest-api-skd-php-master (the demo works btw).

I can show you my code though it pretty precisely emulates the test case.

The only thing I can think of is that the processing files are buried below www access levels?

If you can clean any info from the error logs I'm all ears. If there's more info you need from me I can provide it.

Answers


If you are intending to use sandbox as stated in the first line, then the error is happening because you are calling production PayPal servers.

Change https://api.paypal.com/v1/oauth2/token

To https://api.sandbox.paypal.com/v1/oauth2/token


Need Your Help

How do I return HTTP status code 420 from my WCF service?

c# web-services wcf http-status-codes

My client is requesting to set status code=420 if the WCF service returns an error. How can i achieve it?

Frament transaction with list fragment

java android fragment android-listfragment

I am trying to implement a navigation drawer. "Fragment1" is a list fragment:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.