From 94c6425a2b9c1643371db7d2c3288a7d833aed7a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 15:41:25 +0000 Subject: [PATCH] Address code review: add SlowDownIncrementSeconds constant, return OtherError for device code failures 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 --- MinecraftClient/Protocol/MicrosoftAuthentication.cs | 8 ++++++-- MinecraftClient/Protocol/ProtocolHandler.cs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MinecraftClient/Protocol/MicrosoftAuthentication.cs b/MinecraftClient/Protocol/MicrosoftAuthentication.cs index 50f2397c..4c84ce47 100644 --- a/MinecraftClient/Protocol/MicrosoftAuthentication.cs +++ b/MinecraftClient/Protocol/MicrosoftAuthentication.cs @@ -94,6 +94,10 @@ namespace MinecraftClient.Protocol /// Login response with access token and refresh token public static LoginResponse PollDeviceCodeToken(string deviceCode, int expiresIn, int interval) { + // Per OAuth 2.0 device code spec, server may respond with "slow_down" requiring + // the client to increase its polling interval by this amount + const int SlowDownIncrementSeconds = 5; + string postData = string.Format( "client_id={0}&grant_type=urn:ietf:params:oauth:grant-type:device_code&device_code={1}", clientId, deviceCode); @@ -123,8 +127,8 @@ namespace MinecraftClient.Protocol } else if (error == "slow_down") { - // Server asked us to slow down, increase interval by 5 seconds - pollInterval += 5; + // Server asked us to slow down + pollInterval += SlowDownIncrementSeconds; continue; } else if (error == "expired_token") diff --git a/MinecraftClient/Protocol/ProtocolHandler.cs b/MinecraftClient/Protocol/ProtocolHandler.cs index 7a58c400..9dbd3be8 100644 --- a/MinecraftClient/Protocol/ProtocolHandler.cs +++ b/MinecraftClient/Protocol/ProtocolHandler.cs @@ -808,7 +808,7 @@ namespace MinecraftClient.Protocol ConsoleIO.WriteLineFormatted("§c" + e.StackTrace); } - return LoginResult.WrongPassword; + return LoginResult.OtherError; } }