I can't get an OAuth Token with Java

Sunday, August 9, 2015 - 11:52
Arthur Dent

I have a key and secret for the APIs, but I'm not able to get an OAuth Access Token from the /oauth/token API. I only ever get a 500 Internal Server Error.
Here's what my code looks like:

String auth = key + ":" + secretCombination;

Base64.Encoder encoder = Base64.getEncoder();
String encodedString = encoder.encodeToString(auth.getBytes(StandardCharsets.UTF_8) );

URL url = new URL(path);
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.addRequestProperty("Authorization", "Basic " + encodedString);
httpCon.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");

OutputStreamWriter out = new OutputStreamWriter(

Answer Count: 

When making a request to the Token API, you'll need to make sure you have a few things correct:

  1. Do a POST request to /oauth/token.
  2. Make sure you have the Authentication HTTP header value as Basic HASH
  3. Replace HASH with your key and secret, separated by a colon, and base64-encoded.
  4. Be sure you have a Content-Type HTTP Header with the value application/x-www-form-urlencoded
  5. Lastly you need to send a body with the request: grant_type=client_credentials

Looks like you have steps 1-4 correct but are missing that body.

Sunday, August 9, 2015 - 12:00
Jeof Oyster

Informative update here and that looks pretty interesting. Would like to explore more about the game and also this https://www.collegessaywriter.com/research-paper/ link contains the professional's updates. Keep it up to bring more reliable updates for us.

Saturday, April 13, 2019 - 04:25
Ralph A