In the minecraft authentication page, users send an https post request with a specific format to get a response, which I believe I have used correctly. However, I am getting a Method Not Allowed
error, meaning that the server received something other than a post request, which isn't true.
The server variable:
final String server = "https://authserver.mojang.com/authenticate";
Here is how my payload is sent:
Gson gson = new Gson();
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(server);
StringEntity postingString = new StringEntity(gson.toJson(payload));
post.setEntity(postingString);
post.setHeader("content-type", "application/json");
HttpResponse response = (HttpResponse) httpClient.execute(post);
this.authResponse = response.toString();
This is the NEW full response message I an receiving:
HttpResponseProxy{HTTP/1.1 400 Bad Request [Content-Type: application/json, Content-Length: 655, Connection: keep-alive, Accept-Ranges: bytes, Date: Mon, 01 Jan 2018 15:28:36 GMT, Server: Restlet-Framework/2.3.10, Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept, X-Cache: Error from cloudfront, Via: 1.1 6046e14e05d9aeb3ea5b4dd85091e9a6.cloudfront.net (CloudFront), X-Amz-Cf-Id: 4wciQ7Mp6OExfWnU3C9frmifhqWQT5_vpQRvUbXPrDy-O-nJqPWtWQ==] ResponseEntityProxy{[Content-Type: application/json,Content-Length: 655,Chunked: false]}}
The contents of my request look like this:
{
"agent": {
"name": "Minecraft",
"version": 1
},
"username": "my username",
"password": "my password"
}
Clearer Error Response Message:
{"error":"JsonMappingException","errorMessage":"Can not construct instance of com.mojang.yggdrasil.auth.dataaccess.memcached.throttling.captcha.CaptchaCredentials: no String-argument constructor/factory method to deserialize from String value ('{\n \"agent\": { \n \"name\": \"Minecraft\", \n \"version\": 1 \n \n },\n \"username\": \"my username\", \n \n \"password\": \"my password\"\n}')\n at [Source: HttpInputOverHTTP@5e25d803; line: 1, column: 1]"}