Getting PayPal Access Token not working
I'm getting the response:
"StatusCode: NotFound, Content-Type: application/json, Content-Length: 131)"
My code, using 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);
}
I do have a slight feeling my grant_type
may be incorrect, as I'm not 100% sure what actually goes here, after a bit of research it still isn't clear to me - but I went with refresh_token&refresh_token={refresh_token}
. Although {refresh_token}
is static, I'm not sure if you're supposed to populate this with a value, or how to do so.
Does anybody know what I'm doing wrong - and if my suspicions regarding the issue being the grant_type
being correct?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…