SignInRequest
Only users can use this request. See code examples.
---functions--- auth.signIn#8d52a951 flags:# phone_number:string phone_code_hash:string phone_code:flags.0?string email_verification:flags.1?EmailVerification = auth.Authorization
Returns
auth.Authorization |
This type can be an instance of either:
Authorization | AuthorizationSignUpRequired |
Parameters
phone_number | string | |
phone_code_hash | string | |
phone_code | string | This argument defaults to None and can be omitted. |
email_verification | EmailVerification | This argument defaults to None and can be omitted. |
Known RPC errors
This request can cause 6 known errors:
PhoneCodeEmptyError | The phone code is missing. |
PhoneCodeExpiredError | The confirmation code has expired. |
PhoneCodeInvalidError | The phone code entered was invalid. |
PhoneNumberInvalidError | The phone number is invalid. |
PhoneNumberUnoccupiedError | The phone number is not yet being used. |
SessionPasswordNeededError | Two-steps verification is enabled and a password is required. |
You can import these from telethon.errors
.
Example
Please refer to the documentation of client.sign_in()
to learn about the parameters and see several code examples on how to use it.
The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.
from telethon.sync import TelegramClient from telethon import functions, types with TelegramClient(name, api_id, api_hash) as client: result = client(functions.auth.SignInRequest( phone_number='some string here', phone_code_hash='some string here', phone_code='some string here', email_verification=types.EmailVerificationCode( code='some string here' ) )) print(result.stringify())