mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
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
This commit is contained in:
parent
5147fb42df
commit
94c6425a2b
2 changed files with 7 additions and 3 deletions
|
|
@ -94,6 +94,10 @@ namespace MinecraftClient.Protocol
|
|||
/// <returns>Login response with access token and refresh token</returns>
|
||||
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")
|
||||
|
|
|
|||
|
|
@ -808,7 +808,7 @@ namespace MinecraftClient.Protocol
|
|||
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
|
||||
}
|
||||
|
||||
return LoginResult.WrongPassword;
|
||||
return LoginResult.OtherError;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue