diff --git a/SteamAccountDataFetcher/SteamAccountDataFetcher.csproj b/SteamAccountDataFetcher/SteamAccountDataFetcher.csproj index 25e52de..acb414a 100644 --- a/SteamAccountDataFetcher/SteamAccountDataFetcher.csproj +++ b/SteamAccountDataFetcher/SteamAccountDataFetcher.csproj @@ -9,7 +9,7 @@ Andrii Lavrenko Utility for collecting Steam account information Andrii Lavrenko - 3.0.0 + 3.0.1 diff --git a/SteamAccountDataFetcher/SteamDataClient/Client.cs b/SteamAccountDataFetcher/SteamDataClient/Client.cs index 03aeae9..b8becee 100644 --- a/SteamAccountDataFetcher/SteamDataClient/Client.cs +++ b/SteamAccountDataFetcher/SteamDataClient/Client.cs @@ -78,7 +78,6 @@ internal Client(string username, string password, string sharedSecret) _callbackManager.Subscribe(OnLoggedOn); _callbackManager.Subscribe(OnLoggedOffAsync); _callbackManager.Subscribe(OnLicenseListAsync); - _callbackManager.Subscribe(OnIsLimitedAccount); _autoTwoFactorAuthenticator = new(this, sharedSecret); @@ -118,28 +117,35 @@ internal async Task RunAsync() private async Task LoginAsync() { - CredentialsAuthSession authSession = await _steamClient.Authentication.BeginAuthSessionViaCredentialsAsync(new() - { - Username = Username, - Password = Password, - Authenticator = _autoTwoFactorAuthenticator - }); - - AuthPollResult authPollResult; - try + while (true) { - authPollResult = await authSession.PollingWaitForResultAsync(); - } - catch (AuthenticationException e) - { - Log($"Unable to authenticate user to Steam Client with error {e.Message}.", Logger.Level.Error); - _steamClient.Disconnect(); - return; + try + { + CredentialsAuthSession authSession = await _steamClient.Authentication.BeginAuthSessionViaCredentialsAsync(new() + { + Username = Username, + Password = Password, + Authenticator = _autoTwoFactorAuthenticator + }); + AuthPollResult authPollResult = await authSession.PollingWaitForResultAsync(); + AccessToken = authPollResult.AccessToken; + RefreshToken = authPollResult.RefreshToken; + break; + } + catch (AuthenticationException e) + { + Log($"Unable to authenticate user to Steam Client with error {e.Message}.", Logger.Level.Error); + _steamClient.Disconnect(); + return; + } + catch (TaskCanceledException) + { + Log("Failure to authenticate user to Steam Client. Retrying...", Logger.Level.Warning); + await Task.Delay(1000); + continue; + } } - AccessToken = authPollResult.AccessToken; - RefreshToken = authPollResult.RefreshToken; - _steamUser.LogOn(new() { Username = Username, @@ -207,6 +213,7 @@ private void OnLoggedOn(SteamUser.LoggedOnCallback callback) return; } _responseAccountInfo.SteamId = callback.ClientSteamID.ConvertToUInt64(); + Log("Logged into Steam."); _steamWebClient.InitAsync(); }