sign_in()#

Client.sign_in()#

Authorize a user in Telegram with a valid confirmation code.

Usable by Users Bots
Parameters:
  • phone_number (str) – Phone number in international format (includes the country prefix).

  • phone_code_hash (str) – Code identifier taken from the result of send_code().

  • phone_code (str) – The valid confirmation code you received (either as Telegram message or as SMS in your phone number).

Returns:

User | TermsOfService | bool – On success, in case the authorization completed, the user is returned. In case the phone number needs to be registered first AND the terms of services accepted (with accept_terms_of_service()), an object containing them is returned. In case the phone number needs to be registered, but the terms of services don’t need to be accepted, False is returned instead.

Raises:
  • BadRequest – In case the arguments are invalid.

  • SessionPasswordNeeded – In case a password is needed to sign in.