Я интегрирую PayPal с веб-сайтом, поэтому тестирую учетные записи в песочнице.
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"
Итак, я получил этот ответ.
{"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}
Поэтому я попытался получить список счетов, используя этот токен доступа, как этот.
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"
Но это не сработало, только вернулась ошибка авторизации.
< 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"}
Я пробовал несколько раз, но все время был одним и тем же ~
Пожалуйста, дайте мне знать причину этого.
Спасибо.