Search code examples
telethon

How do I get a 2FA password hint Telethon


I use sign_in in accaunt with enabled two-factor protection.

await client.sign_in(phone=phone, code=code, phone_code_hash=phone_code_hash)

Call raised SessionPasswordNeededError. I need to retrive a password hint field, however, I did not find in the documentation which method is responsible for this? I found a suitable method in Madelineproto, but not in Telethon :(


Solution

  • In v1, GetPasswordRequest returns the hint:

    from telethon import TelegramClient, functions, types
    
    async with TelegramClient(name, api_id, api_hash) as client:
        result = await client(functions.account.GetPasswordRequest())
        print(result.hint)