• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3409
  • Last Modified:


I am trying to implement the Paypal RESTful API to be able to receive payments on my website. At this stage I have been able to make the sample code work.

More specifically I have created a brand new application in VS2013 and copy pasted the following files from the sample API's: PaymentWithCreditCard.aspx, Response.aspx and Configuration.cs. The result is that I can successfully post payments to the sandbox and get a response of an approved payment. So far so good.

Problem N1 - retrieving an access token

I have replaced in the configuration class file the sample standard access token:

        private static string GetAccessToken()
OAuthTokenCredential("EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM", "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM", GetConfig()).GetAccessToken();
            return accessToken;

Open in new window

with the following:

        private static string GetAccessToken()
            var clientId = System.Configuration.ConfigurationManager.AppSettings["clientId"];
            var secretToken = System.Configuration.ConfigurationManager.AppSettings["secretToken"];
            var config = new Dictionary<string, string> { { "mode", "sandbox" } };

            OAuthTokenCredential tokenCredential = new OAuthTokenCredential(clientId, secretToken, config);
            string accessToken = tokenCredential.GetAccessToken();
            return accessToken;

Open in new window

and i have also added in web.config the following:

    <section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK"/>
      <account apiUsername="" apiPassword="" applicationId="" apiSignature="" />
      <add name="mode" value="sandbox" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <add key="clientId" value="***********" />
    <add key="secretToken" value="***********" />

Open in new window

however I get a

Exception in HttpConnection Execute: Invalid HTTP response The remote server returned an error: (401) Unauthorized.

Open in new window

The sample files are from
1 Solution
käµfm³d 👽Commented:
Nothing immediately stands out. Have you debugged through your code to ensure that lines 3 and 4 actually have the correct values?
LambruAuthor Commented:
Issue sorted, was using wrong client id client secret.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now