Fix Microsoft authentication (#2986)

* fix: microsoft login #2979

* fix: typo
This commit is contained in:
Liyan Zhao 2024-04-15 02:07:47 +08:00 committed by GitHub
parent 4104ca082d
commit 9cf23f69a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -43,7 +43,7 @@ public class AuthlibInjectorDownloader implements AuthlibInjectorArtifactProvide
private final Supplier<DownloadProvider> downloadProvider;
/**
* @param artifactsDirectory where to save authlib-injector artifacts
* @param artifactLocation where to save authlib-injector artifacts
*/
public AuthlibInjectorDownloader(Path artifactLocation, Supplier<DownloadProvider> downloadProvider) {
this.artifactLocation = artifactLocation;

View File

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