Hi, I have an issue trying to get an access token from https://sandbox.dwolla.com/oauth/v2/token
According to the docs, I use my key i get from the dashboard for client_id, and secret as client_secret.
I set the content-type to application/x-www-form-urlencoded.
However the response from the serever is as follows:
{“error”:“access_denied”,“error_description”:“Invalid application credentials.”}
Ive tried this several ways including using client_id and client_secret as header parameters… i tried setting them as a json obejct in the body… but either way doesnt seem to work.
Here is the code i used in java:
URL url = new URL("https://sandbox.dwolla.com/oauth/v2/token");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setDoInput(true);
conn.setDoOutput(true);
String data = "";
JSONObject jsonObj = new JSONObject();
jsonObj.put("client_id", "<CLIENT ID>");
jsonObj.put("client_secret", "<CLIENT SECRET>");
jsonObj.put("grant_type", "client_credentials");
data = jsonObj.toString();
byte[] outputInBytes = data.getBytes("UTF-8");
OutputStream os = conn.getOutputStream();
os.write( outputInBytes );
os.close();
System.out.println("Message:" + conn.getResponseMessage());
//System.out.println("Location:" + conn.getHeaderField("Location"));
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();