I'm trying to set up stripe connect (https://stripe.com/docs/connect/standalone-accounts) on my application, but I'm failing to set up the link between the platform and the standalone account. It provides a curl code to execute, and examples in ruby, python, PHP and node; but no java.
The curl call is as follows:
curl https://connect.stripe.com/oauth/token \ -d client_secret=sk_test_IgHHUgcqKmxA8Yyai9ocqpZR \ -d code=AUTHORIZATION_CODE \ -d grant_type=authorization_code
It looks pretty simple, but I have no idea how this works. I have been looking around trying to figure out how to make this call in java, and so far I haven't been able to.
Finally i got the correct code to run the curl command ,but it gives bunch of result.but i want only paricular id in it.how can i get that?
`URL url = new URL("https://connect.stripe.com/oauth/token");
Map<String,Object> params = new LinkedHashMap<>();
params.put("client_secret",API_KEY);
params.put("code", code);
params.put("grant_type", "authorization_code");
StringBuilder postData = new StringBuilder();
for (Map.Entry<String,Object> param : params.entrySet()) {
if (postData.length() != 0) postData.append('&');
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
StringBuilder sb = new StringBuilder();
for (int c; (c = in.read()) >= 0;)
sb.append((char)c);
String response = sb.toString();`
and i got
response={
"access_token": "xxxxxxxxxxxxxxxxx",
"livemode": false,
"refresh_token": "xxxxxxxxxxxxxxxxxxxxxxxt",
"token_type": "bearer",
"stripe_publishable_key": "xxxxxxxxxxxxxxxxxxxxxxxx",
"stripe_user_id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"scope": "express"
}
how can i get only the stripe_user_id in java