Julien Cauchon
Julien Cauchon

Reputation: 59

node js paypal rest sdk 401 error

Hi I'm using nodejs and paypal-rest-sdk "^1.6.0" with express 4.13.1 .

When i make live payement i have this error :

 { [Error: Response Status : 401]
  response:
   { error: 'invalid_client',
     error_description: 'Client Authentication failed',
     httpStatusCode: 401 },
  httpStatusCode: 401 }

But when i use the sandebox host, I don't have any error.

does anybody have an odea of what i doing wrong ?

ps: sorry for my bad english, i do my best ;)

Upvotes: 1

Views: 1161

Answers (1)

Jonathan LeBlanc
Jonathan LeBlanc

Reputation: 788

Based on the error, my first guess would be that you're trying to use your sandbox credentials (client id and secret) when trying to use the live environment.

Here's how you get those credentials:

  • Go to the PayPal Developer Dashboard
  • Click on your application in the list on that page
  • At the top right of the page that opens, you'll see two buttons for "Sandbox" and "Live". Sandbox should be the page that you start on. Click on the "Live" button.
  • You will be given the live client id and secret (just click on the show link to display).

Now, when you are configuring your Node application, use the following (with your client id and secret):

paypal.configure({
  'mode': 'live',
  'client_id': 'YOUR LIVE CLIENT ID',
  'client_secret': 'YOUR LIVE SECRET'
});

Hopefully that should solve the problem.

Upvotes: 4

Related Questions