0
Я пытаюсь создать Java эквивалент этого:Curl сообщение в Java
curl -X POST https://connect.stripe.com/oauth/token \
-d client_secret=sk_test_px1LcMW6VWVSWKrRT4MuHvTY \
-d code=AUTHORIZATION_CODE \
-d grant_type=authorization_code
в Java согласно документу найти здесь: https://stripe.com/docs/connect/oauth#token-request. Это то, к чему я пришел, но я продолжаю неавторизоваться. Я что-то сделал неправильно? Я могу заставить запрос работать корректно с завитом, но не с java.
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost("https://connect.stripe.com/oauth/token");
try
{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("grant_type", "authorization_code"));
nameValuePairs.add(new BasicNameValuePair("code", code));
nameValuePairs.add(new BasicNameValuePair("client_secret", stripeClientId));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null)
{
System.out.println(line);
}
}
catch (IOException e)
{
e.printStackTrace();
}