I'm building a Telegram account automation tool using Telethon in Python. I need to log in to multiple phone numbers, some of which are not yet registered on Telegram.

The problem is that when I call send_code_request(), Telegram sends the login code to the Telegram app (SentCodeTypeApp) instead of via SMS. For unregistered numbers or numbers without an active Telegram session, this makes it impossible to receive the code.

What I've tried:

force_sms=True in send_code_request() — this parameter is deprecated and no longer works in newer versions of Telethon.

Calling ResendCodeRequest after the initial request — this sometimes works, but I'm not confident it's reliable across all account states.

Questions:

Is ResendCodeRequest the correct and reliable way to force SMS delivery in modern Telethon?

Are there any edge cases where this still won't result in an SMS being delivered?

Is there a way to directly request SMS on the first call without needing a resend step?

PouyaKH's user avatar

New contributor

PouyaKH is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

2

No, Telegram has long since disabled SMS login codes for unofficial applications (A.K.A. anything that you would make with Telethon). So it is not possible. See https://t.me/tginfoen/1611 (2023):

Telegram to No Longer Support SMS Requests from Third-Party Apps

According to a recent message that was broadcasted to third-party app developers, Telegram plans to no longer support SMS requests from third-party apps, meaning that users will be able to request SMS verifications only from official Telegram apps.

The change is set to go live on 18th February, at 13:00 UTC. After that date, authorization codes for third-party apps can only be received through official Telegram apps. The message also asked third-party app developers to take necessary actions before that date.

Lonami's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.