获取PayPal访问令牌无效
我得到的回应是:
“statuscode:NotFound,content-type:application/json,content-length:131)”
我的代码,使用RestSharp
public void getToken()
{
var clientId = "{client-ID}";
var secret = "{client-secret}";
if (ServicePointManager.SecurityProtocol != SecurityProtocolType.Tls12) ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // forced to modern day SSL protocols
var client = new RestClient("https://api.paypal.com/v1/oauth2/token") { Encoding = Encoding.UTF8 };
var authRequest = new RestRequest("oauth2/token", Method.POST) { RequestFormat = DataFormat.Json };
client.Authenticator = new HttpBasicAuthenticator(clientId, secret);
authRequest.AddParameter("grant_type", "refresh_token&refresh_token={refresh_token}");
var authResponse = client.Execute(authRequest);
}
我确实有一点感觉,我的
有人知道我做错了什么吗?我对
你把小路折弯了。
new RestClient("https://api.paypal.com/v1/oauth2/token")
这一行将该URL设置为基址,并将其前置到其他路径字符串中。因此,当您使用
https://api.paypal.com/v1/oauth2/token/oauth2/token
只需从基址中删除路径字符串,就可以:
new RestClient("https://api.paypal.com/v1")