I encounter an issue when I try to use the Paypal sandbox API. I've created my 2 sandbox accounts (the facilitator and the buyer), and I've created my app to get the credentials.
Then, I use the curl example provided by Paypal to get a token :
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "my-client-id:my-secret" \
-d "grant_type=client_credentials"
I get a 200 response, with an "access_token".
Then, I use this access token to get another resource, for example :
curl -v -X GET https://api.sandbox.paypal.com/v1/invoicing/invoices?page=3&page_size=4&total_count_required=true \
-H "Content-Type: application/json" \
-H "Authorization: Bearer the-token-received-above"
Then, I get a 401 error : { "name":"AUTHENTICATION_FAILURE", "message":"Authentication failed due to invalid authentication credentials or a missing Authorization header.", "links":[{ "href":"https://developer.paypal.com/docs/api/overview/#error", "rel":"information_link" }] }
I don't understand what I'm doing wrong, since I've followed every step decribed in the Paypal doc (at least, I think I have... probably not)
Thanks for your help
Log in to your sandbox PayPal account. Go to Settings (Gear Icon) > Account Settings > API Access. Select NVP/SOAP API integration (Classic) > Manage API Credentials > Request API Signature. You can find API Username, API Password, and API Signature.
PayPal Sandbox is a virtual testing environment that mimics the live PayPal production environment. It works similarly to making an actual PayPal but without using real credit cards or live PayPal accounts. There are 2 different sandbox account types, Personal and Business.
curl -v -X GET "https://api.sandbox.paypal.com/v1/invoicing/invoices?page=3&page_size=4&total_count_required=true" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer the-token-received-above"
Actually had this exact same issue but didn't know what was wrong with my curl. For me, the issue was I forgot to put "Bearer" in the Authorization section.
For this, you are required to wrap the URL with quotation marks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With