0
私はPayPalの支払いをプロジェクトに組み込もうとしていますが、現時点では失敗しています。PayPal API - (401)アクセストークンをリクエストするときに不正になる
基本的に、最初のステップは、WebRequestで行うことを試みているアクセストークンの要求と応答を取得することですが、私は401を吐き出します。
次の手順:ここhttps://developer.paypal.com/docs/integration/direct/make-your-first-call/
コードです:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
WebRequest request = WebRequest.Create("https://api.sandbox.paypal.com/v1/oauth2/token");
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.Credentials = new NetworkCredential("client_id", "secret");
request.PreAuthenticate = true;
string body = "grant_type=client_credentials";
byte[] buffer = Encoding.UTF8.GetBytes(body);
request.ContentLength = buffer.LongLength;
var reqStr = request.GetRequestStream();
reqStr.Write(buffer, 0, buffer.Length);
reqStr.Close();
WebResponse response = request.GetResponse();
勿論、はと秘密コード:)
はありがとうございにおける実際の値に置き換えられるCLIENT_IDあなたの助け! が