diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloader.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloader.java index 0964a6e1d..3af74b280 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloader.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorDownloader.java @@ -43,7 +43,7 @@ public class AuthlibInjectorDownloader implements AuthlibInjectorArtifactProvide private final Supplier downloadProvider; /** - * @param artifactsDirectory where to save authlib-injector artifacts + * @param artifactLocation where to save authlib-injector artifacts */ public AuthlibInjectorDownloader(Path artifactLocation, Supplier downloadProvider) { this.artifactLocation = artifactLocation; 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 410f942da..79e4a32d1 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 @@ -146,6 +146,16 @@ public class MicrosoftService { long notAfter = minecraftResponse.expiresIn * 1000L + System.currentTimeMillis(); + // Check MC ownership, this is necessary, see GitHub#2979 + HttpURLConnection request = HttpRequest.GET("https://api.minecraftservices.com/entitlements/mcstore") + .authorization("Bearer " + minecraftResponse.accessToken) + .retry(5) + .accept("application/json").createConnection(); + + if (request.getResponseCode() != 200) { + throw new ResponseCodeException(new URL("https://api.minecraftservices.com/entitlements/mcstore"), request.getResponseCode()); + } + // Get Minecraft Account UUID MinecraftProfileResponse profileResponse = getMinecraftProfile(minecraftResponse.tokenType, minecraftResponse.accessToken); handleErrorResponse(profileResponse);