Authentication Failed - Sandbox

SS_2019
Contributor
Contributor

We are currently trying to implement Seller onboarding using the PayPal docs however when we attempt to send the JSON request via JavaScript we are receiving the following error:

 

{"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"}]}

 The auth header is being sent through as such:

xhr.setRequestHeader("Authorization", "Bearer OUR-ACCESS-TOKEN");

This token was generated via the steps on this docs page. We also tested it using the example shown here. This returned:

{total_count: 0, invoices: Array(0), links: Array(1)}

I'm assuming there can not be an error with the Authorization header line if it works for the prior. But then if that is the case I do not understand why this error is being recieved. 

 

Full JS:

var xhr = new XMLHttpRequest();
var url = "https://api.sandbox.paypal.com/v1/customer/partner-referrals";
xhr.open("GET", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer OUR-ACCESS-TOKEN");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) { var json = JSON.parse(xhr.responseText); console.log(json); } }; xhr.send(data);
Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

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