我正在尝试使用 Paypal 设置登录,但我收到一条未经授权的消息 ("{\"error_description\":\"Unable to generate token\",\"error\":\"access_denied\"}")在获取访问令牌时(我收到了授权码而没有打嗝)。我认为我可能错的唯一一件事是这项服务对非美国居民的可用性。它说非美国居民无法使用 REST API,但我注意到它与“使用 Paypal 登录”是分开的。有人知道吗?
这是我正在使用的代码来检索访问令牌,以防任何人注意到错误:
string TokenEndpoint = "https://api.paypal.com/v1/identity/openidconnect/tokenservice";
System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();
reqparm.Add("client_id", this._clientId);
reqparm.Add("client_secret", this._clientSecret);
reqparm.Add("grant_type", "authorization_code");
reqparm.Add("code", authorizationCode);
reqparm.Add("redirect_uri", HttpUtility.UrlEncode(returnUrl.AbsoluteUri));
try
{
using (WebClient client = new WebClient())
{
var data = client.UploadValues(TokenEndpoint, "POST", reqparm); // Access Denied exception occurs here.
...
这是我收到的回复:
HEADER
{
Pragma: no-cache
Vary: Accept-Encoding
Connection: close
Content-Length: 72
Cache-Control: no-store
Content-Type: application/json
Date: Mon, 10 Jun 2013 23:35:02 GMT
Server: Apache-Coyote/1.1
}
Content
text
{
\"error_description\":\"Unable to generate token\",
\"error\":\"access_denied\"
}"