Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST API returning an AUTHORIZATION_ERROR

Following some of the examples provided in the Invoicing REST API https://developer.paypal.com/docs/api/#invoicing I am always receiving an AUTHORIZATION_ERROR.

Here is an example:

First retrieving my token:

curl https://api.sandbox.paypal.com/v1/oauth2/token \
>  -H "Accept: application/json" \
>  -H "Accept-Language: en_US" \
>  -u "AbNzCxxxxs6iVF0:EBhQWxxxxxxrgefvhb" \
>  -d "grant_type=client_credentials"
{"scope":"openid https://uri.paypal.com/services/invoicing https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card/.* https://api.paypal.com/v1/vault/credit-card","access_token":"F9Ig.4FXq1DQICPrMaUUb0-K--3dWBHvqRck636df4A","token_type":"Bearer","app_id":"APP-80W284485P519543T","expires_in":28800}%

Then using that token to create an invoice:

curl -v -X 'POST' 'https://api.sandbox.paypal.com/v1/invoicing/invoices' \
> -H 'Content-Type: application/json' \
> -H 'Authorization: Bearer F9Ig.4FXq1DQICPrMaUUb0-K--3dWBHvqRck636df4A' \
> -d '{
quote>   "merchant_info": {
quote>     "email": "[email protected]",
quote>     "first_name": "Mike",
quote>     "last_name": "Bopp",
quote>     "business_name": "RDG",
quote>     "phone": {
quote>       "country_code": "001",
quote>       "national_number": "5032141716"
quote>     },
quote>     "address": {
quote>       "line1": "1234 Main St.",
quote>       "city": "Portland",
quote>       "state": "OR",
quote>       "postal_code": "97217",
quote>       "country_code": "US"
quote>     }
quote>   }
quote> }'
* Adding handle: conn: 0x7ff110804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7ff110804000) send_pipe: 1, recv_pipe: 0
* About to connect() to api.sandbox.paypal.com port 443 (#0)
*   Trying 23.52.155.39...
* Connected to api.sandbox.paypal.com (23.52.155.39) port 443 (#0)
* TLS 1.2 connection using TLS_RSA_WITH_RC4_128_SHA
* Server certificate: api.sandbox.paypal.com
* Server certificate: VeriSign Class 3 Secure Server CA - G3
* Server certificate: VeriSign Class 3 Public Primary Certification Authority - G5
* Server certificate: Class 3 Public Primary Certification Authority - G2
> POST /v1/invoicing/invoices HTTP/1.1
> User-Agent: curl/7.30.0
> Host: api.sandbox.paypal.com
> Accept: */*
> Content-Type: application/json
> Authorization: Bearer F9Ig.4FXq1DQICPrMaUUb0-K--3dWBHvqRck636df4A
> Content-Length: 387
>
* upload completely sent off: 387 out of 387 bytes
< HTTP/1.1 401 Unauthorized
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< PROXY_SERVER_INFO: host=slcsbjava3.slc.paypal.com;threadId=220
< Paypal-Debug-Id: 0329fb0c0e560
< WWW-Authenticate: OAuth
< Content-Type: application/json
< DC: origin2-api.sandbox.paypal.com
< Date: Fri, 02 May 2014 15:31:53 GMT
< Connection: close
< Set-Cookie: DC=origin2-api.sandbox.paypal.com; secure
<
* Closing connection 0
{"name":"AUTHORIZATION_ERROR","message":"Authorization error occurred.","debug_id":"0329fb0c0e560"}%

I can successfully send a payment request as is done here: https://developer.paypal.com/docs/integration/direct/make-your-first-call/

But for some reason the Invoice does NOT work.
I have verified that in my sandbox app I have enabled invoicing Paypal Authorization Screenshot

Any help appreciated, thanks in advance.

like image 664
Michael Bopp Avatar asked May 02 '14 16:05

Michael Bopp


1 Answers

Please change the email address([email protected]) to the one that linked to the app you created before. Please go ahead to check the email address in your REST APP.

like image 200
PP_MTS_hzhu Avatar answered Nov 01 '22 02:11

PP_MTS_hzhu