PayPal.IdentityException:远程服务器返回错误:(401)未经授权

时间:2018-06-26 07:04:59

标签: asp.net-mvc-4 paypal paypal-sandbox

当我尝试将PayPal付款方式添加到asp.net时出现错误。

这是我的Web.config

      <?xml version="1.0" encoding="UTF-8"?>
  <extension type='component' version = '1.6.0' method = 'upgrade'>
    <name>COM_SHOWHIDE</name>
    <author>Zain Farooq</author>
    <creationDate>JUNE 2018</creationDate>
    <copyright>copyright. All rights reserved</copyright>
    <license>GNU  General Public License version 3 or later</license>
    <authorEmail>zainfarooq541@gmail.com</authorEmail>
    <authorUrl>softbroz.com</authorUrl>
    <version>1.0</version>
    <description>COM_SHOWHIDE_XML_DESCRIPTION</description>
    <administration>
      <files>
        <filename>index.html</filename>
        <filename>showhide.php</filename>
      </files>
      <menu>COM_SHOWHIDE</menu>
    </administration>
  </extension>

这是我的PayPal访问令牌:

 <configSections>
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
 </configSections>

<paypal>
<settings>
  <add name="mode" value="sandbox"/>
  <add name="connectionTimeout" value="360000"/>
  <add name="requestRetries" value="1"/>
  <add name="clientId" value="your client ID of paypal account"/>
  <add name="clientSecret" value="your client secret key of paypal account"/>
</settings>

错误行:

public static string GetAccessToken()
    {
        // getting accesstocken from paypal 
        Dictionary<string, string> payPalConfig = new Dictionary<string, string>();
        payPalConfig.Add("mode", "sandbox");
        OAuthTokenCredential tokenCredential = new OAuthTokenCredential("myCliedId", "myClientSecret", payPalConfig);
        string accessToken = tokenCredential.GetAccessToken();
        return accessToken;

    }

错误描述:PayPal.IdentityException:远程服务器返回错误:(401)未经授权。

请帮助谢谢。

0 个答案:

没有答案