gpt4 book ai didi

c# - 获取我的 Paypal AccessToken 请求

转载 作者:太空宇宙 更新时间:2023-11-03 16:02:18 24 4
gpt4 key购买 nike

我正在尝试获取我的 paypal 访问 token 。

我有下一个参数:EndPoint, Client Id, secret, api username, api签名api密码应用程序Id

我需要一个 paypal 客户端才能这样做吗?

我点击了这个链接:https://developer.paypal.com/docs/integration/direct/make-your-first-call/

并尝试过:

private string getAccessToken() {
var ppClient; // = new paypalClient(); // create a paypal client

Dictionary<string, object> parameters = new Dictionary<string, object>();

parameters.Add("Accept", "application/json");
parameters.Add("Accept-Language", "en_US");
parameters.Add("grant_type", "client_credentials");

var result = ppClient.Get("https://api.sandbox.paypal.com/v1/oauth2/token", parameters);

string accessToken = result["access_token"];
return accessToken;
}

谢谢大家!

最佳答案

我会推荐使用 RestSharp(只需获取 NuGet 包):-

        if (ServicePointManager.SecurityProtocol != SecurityProtocolType.Tls12) ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // forced to modern day SSL protocols
var client = new RestClient(payPalUrl) { Encoding = Encoding.UTF8 };
var authRequest = new RestRequest("oauth2/token", Method.POST) {RequestFormat = DataFormat.Json};
client.Authenticator = new HttpBasicAuthenticator(clientId, secret);
authRequest.AddParameter("grant_type","client_credentials");
var authResponse = client.Execute(authRequest);

关于c# - 获取我的 Paypal AccessToken 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21054150/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com