TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

GetPasswordSetting exception AUTH_KEY_UNREGISTERED

Open hosseinGanjyar opened this issue 8 years ago • 6 comments

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);

hosseinGanjyar avatar Jun 02 '18 08:06 hosseinGanjyar

TLSharp has no documentation. I have the same problem. No answer on Internet.

paramhq avatar Feb 08 '19 15:02 paramhq

That's "known" issue in this library. You can search for open issues under "AUTH_KEY_UNREGISTERED" and you will find a lot.

lazyjohny500 avatar May 22 '19 12:05 lazyjohny500

any solution for this problem?

mafaman2003 avatar Jul 20 '19 16:07 mafaman2003

any solution for this problem?

up........

mafaman2003 avatar Sep 22 '19 02:09 mafaman2003

I've solved my problem with this solution: Telegram authorization goes out

hosseinGanjyar avatar Mar 02 '20 14:03 hosseinGanjyar

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;
    }
}

Muaath5 avatar Jan 16 '21 08:01 Muaath5