0
我使用Paypal Rest APi。當我嘗試獲取訪問令牌時,它給了我未經授權的錯誤。 索引頁遠程服務器返回錯誤:(401)未經授權。同時使用Paypal Rest APi
@Html.ActionLink("Pay with Paypal Account", "PaymentWithPaypal", "Paypal")
的web.config
<configSection>
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSection>
<paypal>
<settings>
<add name="mode" value="sandbox"/>
<add name="connectionTimeout" value="360000"/>
<add name="requestRetries" value="1"/>
<add name="clientId" value="###########"/>
<add name="clientSecret" value="**********"/>
</settings>
</paypal>
<log4net>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="my_app.log"/>
<appendToFile value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] %message%newline"/>
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="FileAppender"/>
</root>
</log4net>
<system.web>
<securityPolicy>
<trustLevel name="Full" policyFile="internal"/>
</securityPolicy>
該錯誤消息是
The remote server returned an error: (401) Unauthorized.
描述:在當前web請求的執行過程中發生了未處理的異常。請查看堆棧跟蹤以獲取有關該錯誤的更多信息以及源代碼的位置。
異常詳細信息:PayPal.IdentityException:上下面的行
string accessToken = new OAuthTokenCredential(ClientId, ClientSecret, GetConfig()).GetAccessToken();
給出在檢查元件下面的消息(401)未經授權
錯誤出現:遠程服務器返回錯誤。
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
我用來集成REST API的代碼可以在這裏 http://www.codeproject.com/Articles/870870/Using-Paypal-Rest-API-with-ASP-NET-MVC
發現任何人都可以請幫我解決這個問題。