Mojang Authentication Server返回Method Not Allowed

时间:2018-01-01 15:04:59

标签: java post minecraft

minecraft authentication page中,用户发送带有特定格式的https发布请求以获得响应,我相信我已经正确使用了该请求。但是,我收到Method Not Allowed错误,这意味着服务器收到了除邮件请求之外的其他内容,但事实并非如此。

服务器变量:

final String server = "https://authserver.mojang.com/authenticate";

以下是我的有效负载的发送方式:

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();

这是我收到的新完整回复消息:

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]}}

我的请求内容如下:

{
"agent": {                              
    "name": "Minecraft",                
    "version": 1                        

},
"username": "my username",      

"password": "my password"
}

更清晰的错误响应消息:

{"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]"}

1 个答案:

答案 0 :(得分:0)

只需使用OpenMCAuthenticator

即可

它只解决了所有问题,甚至会话。