Mojang Authentication Server返回Method Not Allowed

问题描述 投票:2回答:1

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]"}
java post minecraft
1个回答
0
投票

只需使用OpenMCAuthenticator

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

© www.soinside.com 2019 - 2024. All rights reserved.