Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two-step verification for QR Login #3665

Open
thedemons opened this issue Jan 13, 2022 · 1 comment
Open

Two-step verification for QR Login #3665

thedemons opened this issue Jan 13, 2022 · 1 comment
Labels
enhancement Nice to have things that are not a bug

Comments

@thedemons
Copy link

I just recently used qr_login and noticed that it doesn't provide a way to enter a 2FA password.
So I had to come up with this solution:

password = "your password"
qr_login = await client.qr_login()

try:
    await qr_login.wait()

except telethon.errors.SessionPasswordNeededError as e:
    pwd = await client(functions.account.GetPasswordRequest())
    result = await client(
        functions.auth.CheckPasswordRequest(
            pwd_mod.compute_check(pwd, password)
        )
    )

    client._on_login(result.user)

Can you add this feature? It would be nice if we can pass the password argument to qr_login.wait(password=pw) or client.qr_login(password=pw)

@thedemons thedemons added the enhancement Nice to have things that are not a bug label Jan 13, 2022
@shtamtails
Copy link

shtamtails commented Aug 10, 2023

from qrcode import QRCode
from base64 import urlsafe_b64encode as base64url

def gen_qr(token: str):
    qr.clear()
    qr.add_data(token)
    qr.print_ascii()


def display_url_as_qr(url):
    os.system("cls")
    send_info_log("Generated new QR Code...")
    gen_qr(url)

...

qr_login = await client.qr_login()
    r = False
    while not r:
        display_url_as_qr(qr_login.url)
        try:
            r = await qr_login.wait(10)
        except telethon.errors.rpcerrorlist.SessionPasswordNeededError:
            await client.sign_in(password="")
            r = True
        except:
            await qr_login.recreate()
    me = await client.get_me()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Nice to have things that are not a bug
Projects
None yet
Development

No branches or pull requests

2 participants