SendCodeRequest
Only users can use this request. See code examples.
---functions--- auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:CodeSettings = auth.SentCode
Returns
auth.SentCode |
This type can be an instance of either:
SentCode | SentCodeSuccess |
Parameters
phone_number | string | |
api_id | int | |
api_hash | string | |
settings | CodeSettings |
Known RPC errors
This request can cause 10 known errors:
ApiIdInvalidError | The api_id/api_hash combination is invalid. |
ApiIdPublishedFloodError | This API id was published somewhere, you can't use it now. |
AuthRestartError | Restart the authorization process. |
InputRequestTooLongError | The input request was too long. This may be a bug in the library as it can occur when serializing more bytes than it should (like appending the vector constructor code at the end of a message). |
PhoneNumberAppSignupForbiddenError | You can't sign up using this app. |
PhoneNumberBannedError | The used phone number has been banned from Telegram and cannot be used anymore. Maybe check https://www.telegram.org/faq_spam. |
PhoneNumberFloodError | You asked for the code too many times.. |
PhoneNumberInvalidError | The phone number is invalid. |
PhonePasswordFloodError | You have tried logging in too many times. |
PhonePasswordProtectedError | This phone is password protected. |
You can import these from telethon.errors
.
Example
Please refer to the documentation of client.send_code_request()
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.SendCodeRequest( phone_number='some string here', api_id=42, api_hash='some string here', settings=types.CodeSettings( allow_flashcall=True, current_number=True, allow_app_hash=True, allow_missed_call=True, allow_firebase=True, unknown_number=True, logout_tokens=[b'arbitrary\x7f data \xfa here'], token='some string here', app_sandbox=False ) )) print(result.stringify())