REST API Payments get error 401 UNAUTHORIZED in live credentials

deep9993
New Community Member

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

Login to Me Too
4 REPLIES 4

bd9000
Contributor
Contributor

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!

Login to Me Too

Jeckoso
Contributor
Contributor

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

Login to Me Too

MTS_Stefan
Moderator
Moderator
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
Login to Me Too

franktko
Contributor
Contributor

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.

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.