From 15c8c8b714314aa5f2bc22772d54b439f94bb45a Mon Sep 17 00:00:00 2001 From: Archi Date: Fri, 14 Apr 2023 10:43:33 +0200 Subject: [PATCH] Add handling of AccessDenied during login procedure --- ArchiSteamFarm/Steam/Bot.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ArchiSteamFarm/Steam/Bot.cs b/ArchiSteamFarm/Steam/Bot.cs index ab131e703..dddbd4032 100644 --- a/ArchiSteamFarm/Steam/Bot.cs +++ b/ArchiSteamFarm/Steam/Bot.cs @@ -2037,6 +2037,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } break; + case EResult.AccessDenied: // Usually means refresh token is no longer authorized to use, otherwise just try again case EResult.AccountLoginDeniedNeedTwoFactor: case EResult.DuplicateRequest: // This will happen if user reacts to popup and tries to use the code afterwards, we have the code saved in ASF, we just need to try again case EResult.FileNotFound: // User denied approval despite telling us that he accepted it, just try again @@ -2064,6 +2065,7 @@ public sealed class Bot : IAsyncDisposable, IDisposable { } break; + case EResult.AccessDenied when string.IsNullOrEmpty(BotDatabase.RefreshToken) && (++LoginFailures >= MaxLoginFailures): case EResult.InvalidPassword when string.IsNullOrEmpty(BotDatabase.RefreshToken) && (++LoginFailures >= MaxLoginFailures): LoginFailures = 0; ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.BotInvalidPasswordDuringLogin, MaxLoginFailures)); @@ -2565,12 +2567,14 @@ public sealed class Bot : IAsyncDisposable, IDisposable { case EResult.AccountDisabled: // Do not attempt to reconnect, those failures are permanent return; + case EResult.AccessDenied when !string.IsNullOrEmpty(BotDatabase.RefreshToken): case EResult.InvalidPassword when !string.IsNullOrEmpty(BotDatabase.RefreshToken): // We can retry immediately BotDatabase.RefreshToken = null; ArchiLogger.LogGenericInfo(Strings.BotRemovedExpiredLoginKey); break; + case EResult.AccessDenied: case EResult.RateLimitExceeded: ArchiLogger.LogGenericInfo(string.Format(CultureInfo.CurrentCulture, Strings.BotRateLimitExceeded, TimeSpan.FromMinutes(LoginCooldownInMinutes).ToHumanReadable()));