GetPasswordSetting exception AUTH_KEY_UNREGISTERED
I want using GetPasswordSetting for MakeAuthWithPasswordAsync, but after SendCodeRequestAsync, when I want get password setting, throw below error:
AUTH_KEY_UNREGISTERED
code:
client = new TelegramClient(apiId, apiHash);
hash = await client.SendCodeRequestAsync("any");
//-----
var password = await client.GetPasswordSetting(); // throw exception
var password_str = "any";
var user = await client.MakeAuthWithPasswordAsync(password, password_str);
TLSharp has no documentation. I have the same problem. No answer on Internet.
That's "known" issue in this library. You can search for open issues under "AUTH_KEY_UNREGISTERED" and you will find a lot.
any solution for this problem?
any solution for this problem?
up........
I've solved my problem with this solution: Telegram authorization goes out
Use this code:
Note: CloudPasswordNeededException is not exception, but it lets you to add password auth
TelegramClient.ConnectAsync();
Console.Write("Enter your phone number: ");
string phone = Console.ReadLine();
string codeHash = await TelegramClient.SendCodeRequestAsync(phone);
Console.Write("Enter your Telegram code: ");
string code = Console.ReadLine();
TLUser user;
try
{
user = await TelegramClient.MakeAuthAsync(phone, code, codeHash);
}
catch (CloudPasswordNeededException)
{
TLPassword passwordSetting = await TelegramClient.GetPasswordSetting();
Console.WriteLine("This account needs cloud password.");
TryAgain:
Console.Write("Enter your password: ");
string password = Console.ReadLine();
try
{
user = await TelegramClient.MakeAuthWithPasswordAsync(password, passwordSetting);
}
catch // If wrong password
{
Console.WriteLine("Hint: " + passwordSetting.Hint);
if (passwordSetting.HasRecovery)
{
Console.WriteLine("Do you want to reset your password? [Y|N]");
string answer = Console.ReadLine();
if (answer == "Y")
{
Console.WriteLine("Recovery email: " + passwordSetting.EmailUnconfirmedPattern);
// Recover password
Console.Write("Enter email recovery code: ");
string recoveryCode = Console.ReadLine();
TelegramClient.SendRequestAsync<TLRequestRecoverPassword>(new TLRequestRecoverPassword() { Code = recoveryCode });
}
}
else
{
Console.WriteLine("This account doesn't have recovery!");
}
goto TryAgain;
}
}