D
D
de_iiah_teji9_iiace2018-07-10 12:49:02
Django
de_iiah_teji9_iiace, 2018-07-10 12:49:02

Why Authorization error occurred with a valid token?

I tried to make an invoice through PayPal-Python-SDK, but I got an Authorization error occurred error, now I'm trying to do the same through curl.

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

I get an answer
{'access_token': 'ТУТ МОЙ ТОКЕН',
 'app_id': 'APP-ХХХХХХХХХХХХХХХХ',
 'expires_in': 29912,
 'nonce': '2018-07-10T09:04:19ZnUeXNMkpgbjbrDSPYJwFnBGh4LdtU4ORtRsMHLXANvE',
 'scope': 'https://uri.paypal.com/services/paypalhere '
          'https://api.paypal.com/v1/payments/.* '
          'https://uri.paypal.com/services/payments/initiatepayment '
          'https://uri.paypal.com/services/payments/refund '
          'https://uri.paypal.com/services/applications/webhooks '
          '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/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',
 'token_type': 'Bearer'}

I take my token and try to make an invoice
curl -v -X POST https://api.sandbox.paypal.com/v1/invoicing/invoices/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ТУТ МОЙ ТОКЕН" \
-d '{
  "merchant_info": {
    "email": "[email protected]",
    "first_name": "David",
    "last_name": "Larusso",
    "business_name": "Mitchell & Murray",
    "phone": {
      "country_code": "001",
      "national_number": "4085551234"
    },
    "address": {
      "line1": "1234 First Street",
      "city": "Anytown",
      "state": "CA",
      "postal_code": "98765",
      "country_code": "US"
    }
  },
  "billing_info": [
    {
      "email": "[email protected]",
      "first_name": "Stephanie",
      "last_name": "Meyers"
    }
  ],
  "shipping_info": {
    "first_name": "Stephanie",
    "last_name": "Meyers",
    "address": {
      "line1": "1234 Main Street",
      "city": "Anytown",
      "state": "CA",
      "postal_code": "98765",
      "country_code": "US"
    }
  },
  "items": [
    {
      "name": "Zoom System wireless headphones",
      "quantity": 2,
      "unit_price": {
        "currency": "USD",
        "value": "120"
      },
      "tax": {
        "name": "Tax",
        "percent": 8
      }
    },
    {
      "name": "Bluetooth speaker",
      "quantity": 1,
      "unit_price": {
        "currency": "USD",
        "value": "145"
      },
      "tax": {
        "name": "Tax",
        "percent": 8
      }
    }
  ],
  "discount": {
    "percent": 1
  },
  "shipping_cost": {
    "amount": {
      "currency": "USD",
      "value": "10"
    }
  },
  "note": "Thank you for your business.",
  "terms": "No refunds after 30 days."
}'

And I still get the error
{"name":"AUTHORIZATION_ERROR","message":"Authorization error occurred.","information_link":"https://developer.paypal.com/docs/api/invoicing/#errors","debug_id":"c26d163a87c8d"}

Who came across, tell me, pliz, what's wrong, otherwise I'm already sick of banging my head against the wall (

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question