cancel
Showing results for 
Search instead for 
Did you mean: 

Paypal bearer token key doesn't work in curl cli

Contributor

Paypal bearer token key doesn't work in curl cli

I am integrating paypal with website, so testing sandbox accounts.

 

curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "client_id:secret" \
-d "grant_type=client_credentials"

 


So I got this response.

 

{"scope":"https://uri.paypal.com/services/paypalhere https://api.paypal.com/v1/payments/.* https://uri.paypal.com/services/payments/refund https://uri.paypal.com/services/applications/webhooks https://uri.paypal.com/services/invoicing https://uri.paypal.com/services/payments/payment/authcapture https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.* https://api.paypal.com/v1/payments/refund https://uri.paypal.com/services/reporting/search/read https://uri.paypal.com/services/identity/activities https://uri.paypal.com/services/disputes/read-seller https://uri.paypal.com/services/subscriptions https://uri.paypal.com/services/disputes/read-buyer https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/payments/sale/.*/refund openid https://uri.paypal.com/services/disputes/update-seller https://uri.paypal.com/services/payments/realtimepayment",
"nonce":"2019-01-09T05:22:13ZiZajL9aeg05_piYJJ4Ahq11s0FbUiJarNAnFDoEPZQw",
"access_token":"A21AAEfztNgn--7s73LnfG_YnpfR93XQHrB1vOaUJp0tYfhA3J7y_wb8Zj8fMna9SSimQ1Pdhf9bdacR1CmiYNcZn7RS164nA",
"token_type":"Bearer",
"app_id":"APP-80W284485P519543T",
"expires_in":32364}

So I tried to get invoice list using this access token like this.

 

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 A21AAEfztNgn--7s73LnfG_YnpfR93XQHrB1vOaUJp0tYfhA3J7y_wb8Zj8fMna9SSimQ1Pdhf9bdacR1CmiYNcZn7RS164nA"

But it didn't work, only returned authorization error.

< HTTP/1.1 401 Unauthorized
< Date: Wed, 09 Jan 2019 05:30:32 GMT
< Server: Apache
< paypal-debug-id: 7aa8ce0862f88
< HTTP_X_PP_AZ_LOCATOR: sandbox.slc
< Paypal-Debug-Id: 7aa8ce0862f88
< Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D4169545052%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Wed, 09 Jan 2019 06:00:32 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
< Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
< Content-Length: 244
< Connection: close
< Content-Type: application/json
< 
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
{"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 tried several times, but was same all the time ~
Please let me know the reason of this.
Thank you.