【发布时间】:2022-10-30 09:47:41
【问题描述】:
我正在尝试通过 XboxLive 对用户进行身份验证,但在关注 this 文章时遇到了一些麻烦,但我无法通过第一步它总是返回 400: Bad Request
我做了一些挖掘,有些人说将d= 放在 accessToken 之前,但这没有帮助。
public void getXboxLiveToken() throws IOException{
if (this.accessTokenJson == null) getAccessToken();
Header[] headers = new Header[2];
headers[0] = applicationJsonContentTypeHeader;
headers[1] = applicationAcceptJsonHeader;
HttpPost httpPost = new HttpPost(SIGNIN_XBL_URL);
httpPost.setHeaders(headers);
String jsonString = this.gson.toJson(new SignIntoXBLJson(this.accessTokenJson.getAccessToken()));
StringEntity requestEntity = new StringEntity(jsonString, ContentType.APPLICATION_JSON);
httpPost.setEntity(requestEntity);
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
byte[] responseBytes = response.getEntity().getContent().readAllBytes();
System.out.println(response.getStatusLine().getStatusCode() + ": " + response.getStatusLine().getReasonPhrase());
System.out.println(new String(responseBytes));
}
}
json
{
"Properties": {
"AuthMethod": "RPS",
"SiteName": "user.auth.xboxlive.com",
"RspTicket": "d=<Access Token>"
},
"ReplyingParty": "http://auth.xboxlive.com",
"TokenType": "JWT"
}
【问题讨论】: