public async Task InitializeAndAuthenticateClientAsync() { await ConnectAsync(); if (!IsUserAuthorized) { try { Console.WriteLine($"We've sent a code with an activation code to yout phone {ConfigurationManager.PhoneNumber}."); AuthSentCode codeRequest = await _client.SendCode(ConfigurationManager.PhoneNumber, VerificationCodeDeliveryType.NumericCodeViaTelegram); ConfigurationManager.PhoneCodeHash = codeRequest.phoneCodeHash; Console.WriteLine("Code: "); var code = Console.ReadLine(); await _client.SignIn(ConfigurationManager.PhoneNumber, ConfigurationManager.PhoneCodeHash, code); Debug.WriteLine($"User login. Current user is {_client.AuthenticatedUser.firstName} {_client.AuthenticatedUser.lastName}"); } catch (FloodWaitException ex) { await Task.Delay(ex.TimeToWait); await InitializeAndAuthenticateClientAsync(); } } }