sign_in_qrcode()

Client.sign_in_qrcode()

Request a QR code login token and display it in the terminal.

This method exports a login token from Telegram, renders it as an ASCII QR code in the terminal, and returns immediately. Call it in a loop alongside authorize_qr() when you need fine-grained control; for the fully-managed flow use start() with use_qr=True instead.

Usable by Users Bots

Parameters:

except_ids (List of int, optional) – Already logged-in user IDs to exclude, so the same account cannot be authorized twice via the same QR session.

Returns:

User – When the QR code was already scanned and authorization completed in this single call.

LoginToken: When the QR code has been displayed and is awaiting a scan.

Raises:
  • ImportError – The qrcode package is not installed.

  • SessionPasswordNeeded – The account has 2FA enabled; handle this by prompting for and checking the password.