API Authentication failed due to invalid authentication credentials or a missing

eibachcv
Contributor
Contributor

Hello,

I am trying to set up a POST request to the Order API. I have my authentication working and getting an access_token back, but when I try to send my Order request, it says "Authentication failed due to invalid authentication credentials or a missing..."

Login to Me Too
1 REPLY 1

MTS_Jennifer
Moderator
Moderator

Hi @eibachcv ,

Thank you for posting to the PayPal Merchant Community. 

The error message usually means that the access token is missing from the headers. Once you get the access token, make certain that you are sending it in the request. The request should look something like this (make sure to pass your access_token into the Authorization: Bearer header: 

https://developer.paypal.com/docs/api/orders/v2/#orders_create -> has examples in Payload, cURL, Node.js, Java, Python

 

curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders \
-H 'Content-Type: application/json' \
-H 'PayPal-Request-Id: 7b92603e-77ed-4896-8e78-5dea2050476a' \
-H 'Authorization: Bearer {{access_token}}' \
-d '{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
      "amount": {
        "currency_code": "USD",
        "value": "100.00"
      }
    }
  ],
  "payment_source": {
    "paypal": {
      "experience_context": {
        "payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
        "payment_method_selected": "PAYPAL",
        "brand_name": "EXAMPLE INC",
        "locale": "en-US",
        "landing_page": "LOGIN",
        "shipping_preference": "SET_PROVIDED_ADDRESS",
        "user_action": "PAY_NOW",
        "return_url": "https://example.com/returnUrl",
        "cancel_url": "https://example.com/cancelUrl"
      }
    }
  }
}' 

 

 

Thank you,

Jennifer

PayPal

MTS

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.