Replace PPFT/urlPost HTML scraping with OAuth 2.0 device code flow for 2FA support

- Add Microsoft.RequestDeviceCode() and Microsoft.PollDeviceCodeToken() methods
- Remove XboxLive.PreAuth() and XboxLive.UserLogin() (HTML scraping)
- Remove PreAuthResponse struct, PPFT/urlPost regex patterns
- Update XblAuthenticate to always use "d=" prefix for OAuth tokens
- Update MicrosoftMCCLogin to use device code flow
- Skip password prompting for Microsoft device code method
- Add translation strings for device code prompts
- Update config comments and documentation

Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/e13b31f3-8d76-4240-bb69-a519a145fc6a
This commit is contained in:
copilot-swe-agent[bot] 2026-03-23 15:38:47 +00:00
parent daeec49789
commit 5147fb42df
8 changed files with 176 additions and 154 deletions

View file

@ -390,6 +390,8 @@ namespace MinecraftClient
//Asking the user to type in missing data such as Username and Password
bool useBrowser = Config.Main.General.AccountType == LoginType.microsoft && Config.Main.General.Method == LoginMethod.browser;
bool useDeviceCode = Config.Main.General.AccountType == LoginType.microsoft && Config.Main.General.Method == LoginMethod.mcc;
bool skipPassword = useBrowser || useDeviceCode;
if (string.IsNullOrWhiteSpace(InternalConfig.Account.Login) && !useBrowser)
{
ConsoleIO.WriteLine(ConsoleIO.BasicIO ? Translations.mcc_login_basic_io : Translations.mcc_login);
@ -401,7 +403,7 @@ namespace MinecraftClient
}
}
InternalConfig.Username = InternalConfig.Account.Login;
if (string.IsNullOrWhiteSpace(InternalConfig.Account.Password) && !useBrowser &&
if (string.IsNullOrWhiteSpace(InternalConfig.Account.Password) && !skipPassword &&
(Config.Main.Advanced.SessionCache == CacheType.none || !SessionCache.Contains(ToLowerIfNeed(InternalConfig.Account.Login))))
{
RequestPassword();
@ -475,7 +477,7 @@ namespace MinecraftClient
if (result != ProtocolHandler.LoginResult.Success
&& string.IsNullOrWhiteSpace(InternalConfig.Account.Password)
&& !(Config.Main.General.AccountType == LoginType.microsoft && Config.Main.General.Method == LoginMethod.browser))
&& !(Config.Main.General.AccountType == LoginType.microsoft))
RequestPassword();
}
else ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_session_valid, session.PlayerName));
@ -594,7 +596,7 @@ namespace MinecraftClient
}
if ((Config.Main.General.AccountType == LoginType.microsoft || Config.Main.General.AccountType == LoginType.yggdrasil)
&& (InternalConfig.Account.Password != "-" || Config.Main.General.Method == LoginMethod.browser)
&& InternalConfig.Account.Password != "-"
&& Config.Signature.LoginWithSecureProfile
&& protocolversion >= 759 /* 1.19 and above */
&& !string.IsNullOrWhiteSpace(session.ID))