diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index 40443994c..c768b00ed 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -849,14 +849,14 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { return false; } task.cleanup(); // player is online -> remove pending authentication immediately - return task.getAuthentication().handle((response, ex) -> { + return task.getAuthentication().handle((result, ex) -> { if (ex != null) { geyser.getLogger().error("Failed to log in with Microsoft code!", ex); disconnect(ex.toString()); return false; } - StepMCProfile.MCProfile mcProfile = response.getMcProfile(); + StepMCProfile.MCProfile mcProfile = result.session().getMcProfile(); StepMCToken.MCToken mcToken = mcProfile.getMcToken(); this.protocol = new MinecraftProtocol( @@ -871,8 +871,8 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { return false; } - // Save our refresh token for later use - geyser.saveAuthChain(bedrockUsername(), mcToken.getXblXsts().getInitialXblSession().getMsaToken().getRefreshToken()); + // Save our auth chain for later use + geyser.saveAuthChain(bedrockUsername(), GSON.toJson(result.step().toJson(result.session()))); return true; }).join(); } diff --git a/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java b/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java index e95dd370b..54c3a7e80 100644 --- a/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java +++ b/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java @@ -99,7 +99,7 @@ public class PendingMicrosoftAuthentication { private final String userKey; private final int timeoutSec; @Getter - private CompletableFuture authentication; + private CompletableFuture authentication; private AuthenticationTask(String userKey, int timeoutSec) { this.userKey = userKey; @@ -123,11 +123,11 @@ public class PendingMicrosoftAuthentication { authentications.invalidate(userKey); } - public CompletableFuture performLoginAttempt(boolean offlineAccess, Consumer deviceCodeConsumer) { + public CompletableFuture performLoginAttempt(boolean offlineAccess, Consumer deviceCodeConsumer) { return authentication = CompletableFuture.supplyAsync(() -> { try { - return AUTH_FLOW.apply(offlineAccess, timeoutSec) - .getFromInput(AUTH_CLIENT, new StepMsaDeviceCode.MsaDeviceCodeCallback(deviceCodeConsumer)); + StepFullJavaSession step = AUTH_FLOW.apply(offlineAccess, timeoutSec); + return new StepChainResult(step, step.getFromInput(AUTH_CLIENT, new StepMsaDeviceCode.MsaDeviceCodeCallback(deviceCodeConsumer))); } catch (Exception e) { throw new CompletionException(e); } @@ -153,4 +153,7 @@ public class PendingMicrosoftAuthentication { super(userKey, timeoutSec); } } + + public record StepChainResult(StepFullJavaSession step, StepFullJavaSession.FullJavaSession session) { + } }