From 74abecaae756482d4db0807f5301d04dc71c8f53 Mon Sep 17 00:00:00 2001 From: Burning_TNT <88144530+burningtnt@users.noreply.github.com> Date: Mon, 22 Jul 2024 23:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=20#3095=20=E5=BE=AE=E8=BD=AF?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=95=8C=E9=9D=A2=E5=AF=B9=20XBox=20400=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=BB=99=E4=BA=88=E6=8F=90=E7=A4=BA=20(#3194?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmcl/auth/microsoft/MicrosoftService.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/microsoft/MicrosoftService.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/microsoft/MicrosoftService.java index ae3bc1b8c..214f062de 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/microsoft/MicrosoftService.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/microsoft/MicrosoftService.java @@ -112,21 +112,23 @@ public class MicrosoftService { } private MicrosoftSession authenticateViaLiveAccessToken(String liveAccessToken, String liveRefreshToken) throws IOException, JsonParseException, AuthenticationException { - // Authenticate with XBox Live - XBoxLiveAuthenticationResponse xboxResponse = HttpRequest - .POST("https://user.auth.xboxlive.com/user/authenticate") - .json(mapOf( - pair("Properties", - mapOf(pair("AuthMethod", "RPS"), pair("SiteName", "user.auth.xboxlive.com"), - pair("RpsTicket", "d=" + liveAccessToken))), - pair("RelyingParty", "http://auth.xboxlive.com"), pair("TokenType", "JWT"))) - .retry(5) - .accept("application/json").getJson(XBoxLiveAuthenticationResponse.class); - - String uhs = getUhs(xboxResponse, null); - - XBoxLiveAuthenticationResponse minecraftXstsResponse; + String uhs; + XBoxLiveAuthenticationResponse xboxResponse, minecraftXstsResponse; try { + // Authenticate with XBox Live + xboxResponse = HttpRequest + .POST("https://user.auth.xboxlive.com/user/authenticate") + .json(mapOf( + pair("Properties", + mapOf(pair("AuthMethod", "RPS"), pair("SiteName", "user.auth.xboxlive.com"), + pair("RpsTicket", "d=" + liveAccessToken))), + pair("RelyingParty", "http://auth.xboxlive.com"), pair("TokenType", "JWT"))) + .retry(5) + .accept("application/json") + .getJson(XBoxLiveAuthenticationResponse.class); + + uhs = getUhs(xboxResponse, null); + minecraftXstsResponse = HttpRequest .POST("https://xsts.auth.xboxlive.com/xsts/authorize") .json(mapOf(