PayPal.IdentityException: The remote server returned an error: (401) Unauthorized.

daverook
Contributor
Contributor

My question is nearly identical to 

https://www.paypal-community.com/t5/REST-APIs/PayPal-IdentityException-The-remote-server-returned-an...

 

but I will explain what the difference is. 

 

It's my first time consuming the PayPal API. I'm following the Quick Start at GitHub https://github.com/paypal/PayPal-NET-SDK/wiki/Quick-Start

 

My app.confg file

 

 <paypal>
    <settings>
      <add name="mode" value="sandbox" />
      <add name="clientId" value="***" />
      <add name="clientSecret" value="***" />
    </settings>
  </paypal>

 

My C# code is executing from a test class. The relevant (failing) part of the code is 

 

    

var config = ConfigManager.Instance.GetProperties();  //returns a dictionary with 3 items
var accessToken = new OAuthTokenCredential(config).GetAccessToken(); // fails

 

Examining the exception shows  it is an Identity Exception, and the response is

 

    "{\"error\":\"invalid_client\",\"error_description\":\"Client Authentication failed\"}" 

 

Sadly, this is where I'm now lost. I understand it is saying the issue is the client is invalid, and as such, I initially guessed I have probably provided the wrong ClientID, but I don't feel this is the case. 

 

Within PayPal -> All Tools -> API Credentials I click on Manage API credentials, authenticate myself and see my Client ID and Client Secret. I copy and paste these into my app.config file but the same error messages persists. 

 

Another look at https://github.com/paypal/PayPal-NET-SDK/wiki/Configuration shows that I need to have built a webapp. Sadly, the links in that document do not work so, I'm now lost. Am I supposed to get the auth details as I described above, or do I still need to create a webapp within PayPal?

 

 

Login to Me Too
1 ACCEPTED SOLUTION
1 REPLY 1

Haven't Found your Answer?

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