cancel
Showing results for 
Search instead for 
Did you mean: 

REST API Payments get error 401 UNAUTHORIZED in live credentials

New Community Member

REST API Payments get error 401 UNAUTHORIZED in live credentials

REST API Payments get error 401 UNAUTHORIZED , When using live credentials, in testing  credentials all working ok

4 REPLIES
Contributor

Re: REST API Payments get error 401 UNAUTHORIZED in live credentials

Did you ever find a solution to this bug? Please share if you did.
I've been pulling my hair out for weeks on this one and there are no answers anywhere.
Thanks!

Member

Re: REST API Payments get error 401 UNAUTHORIZED in live credentials

I had the same problem and solve as following:

 

// set config
Dictionary<string,string> config = new Dictionary<string,string>();

config.Add("mode", "live");

config.Add("clientId", "xxx");
config.Add("clientSecret", "xxx");


var accessToken = new OAuthTokenCredential(config).GetAccessToken(); // get the GetAccessToken with the config

var apiContext = new APIContext(accessToken);

apiContext.Config = config; // no need in "sandbox" mode, but need in "live" mode

 

hope it helps

Moderator

Re: REST API Payments get error 401 UNAUTHORIZED in live credentials

Hello Guys,

When you use REST, you need to use the Client ID and Secret when requesting an access token, in order to do all the API calls your account is able to.

https://developer.paypal.com/docs/api/overview/#authentication-and-authorization

Kind Regards,
Stefan
New Community Member

Re: REST API Payments get error 401 UNAUTHORIZED in live credentials

Yes, as Jeckoso said... I'm using MVC and in my Web.config file, I have the ClientID and the Secret but there is a third argument called mode which can be 'sandbox' or 'live'. Going with live credentials with the mode sandbox will throw the not authorized exception.