Use direct verification uri for bedrock login

This commit is contained in:
FlorianMichael 2023-12-03 21:23:15 +01:00
parent 995fb20f6a
commit 4ca7bce0f1
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
2 changed files with 8 additions and 11 deletions

View File

@ -26,7 +26,7 @@ import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.base.BooleanSetting; import de.florianmichael.viafabricplus.settings.base.BooleanSetting;
import de.florianmichael.viafabricplus.settings.base.ButtonSetting; import de.florianmichael.viafabricplus.settings.base.ButtonSetting;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConfirmScreen; import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.text.MutableText; import net.minecraft.text.MutableText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Util; import net.minecraft.util.Util;
@ -40,6 +40,7 @@ import java.net.URISyntaxException;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class BedrockSettings extends SettingGroup { public class BedrockSettings extends SettingGroup {
private static final BedrockSettings instance = new BedrockSettings(); private static final BedrockSettings instance = new BedrockSettings();
public final ButtonSetting _1 = new ButtonSetting(this, Text.translatable("bedrock_settings.viafabricplus.click_to_set_bedrock_account"), () -> CompletableFuture.runAsync(this::openBedrockAccountLogin)) { public final ButtonSetting _1 = new ButtonSetting(this, Text.translatable("bedrock_settings.viafabricplus.click_to_set_bedrock_account"), () -> CompletableFuture.runAsync(this::openBedrockAccountLogin)) {
@ -65,16 +66,12 @@ public class BedrockSettings extends SettingGroup {
try { try {
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) { try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
final var bedrockSession = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> { final var bedrockSession = MinecraftAuth.BEDROCK_DEVICE_CODE_LOGIN.getFromInput(httpClient, new StepMsaDeviceCode.MsaDeviceCodeCallback(msaDeviceCode -> {
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new ConfirmScreen(consumer -> { MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> {
if (consumer) { MinecraftClient.getInstance().setScreen(prevScreen);
MinecraftClient.getInstance().keyboard.setClipboard(msaDeviceCode.getUserCode()); Thread.currentThread().interrupt();
} else { }, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrock.viafabricplus.login"), Text.translatable("base.viafabricplus.cancel"), true)));
MinecraftClient.getInstance().setScreen(prevScreen);
Thread.currentThread().interrupt();
}
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrock.viafabricplus.login", msaDeviceCode.getUserCode()), Text.translatable("base.viafabricplus.copy_code"), Text.translatable("base.viafabricplus.cancel"))));
try { try {
Util.getOperatingSystem().open(new URI(msaDeviceCode.getVerificationUri())); Util.getOperatingSystem().open(new URI(msaDeviceCode.getDirectVerificationUri()));
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
VFPScreen.showErrorScreen("Microsoft Bedrock Login", e, prevScreen); VFPScreen.showErrorScreen("Microsoft Bedrock Login", e, prevScreen);

View File

@ -82,7 +82,7 @@
"visual_settings.viafabricplus.enable_sword_blocking": "Enable sword animation", "visual_settings.viafabricplus.enable_sword_blocking": "Enable sword animation",
"visual_settings.viafabricplus.enable_block_hit_animation": "Enable block hit animation", "visual_settings.viafabricplus.enable_block_hit_animation": "Enable block hit animation",
"bedrock.viafabricplus.login": "Your browser should have opened.\nPlease enter the following Code: %s\nClosing this screen will cancel the process!", "bedrock.viafabricplus.login": "Your browser should have opened.\nClosing this screen will cancel the process!",
"bedrock.viafabricplus.confirm_transfer_server_prompt": "Do you want to transfer to the following server?\n%s\n\nThis will disconnect the current server and connect to the new one.", "bedrock.viafabricplus.confirm_transfer_server_prompt": "Do you want to transfer to the following server?\n%s\n\nThis will disconnect the current server and connect to the new one.",
"authentication.viafabricplus.failed_to_verify_session": "ViaFabricPlus failed to verify your session! Please log in into an Account or disable the BetaCraft authentication in the ViaFabricPlus Settings", "authentication.viafabricplus.failed_to_verify_session": "ViaFabricPlus failed to verify your session! Please log in into an Account or disable the BetaCraft authentication in the ViaFabricPlus Settings",