Telethon: send_code_request not sending SMS

Checklist

  • The error is in the library’s code, and not in my own.
  • I have searched for this issue before posting it and there isn’t a duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip and triggered the bug in the latest version.

Code that causes the issue

from telethon.sync import TelegramClient

session_path = Path("sessions")
if not session_path.exists():
    session_path.mkdir()

phone_number = get_phone_number()
client = TelegramClient(f"sessions/{phone_number}", api_id, api_hash, proxy=proxy)


async def main():
    await client.connect()

    await client.send_code_request(f"+{phone_number}", force_sms=True)
    verification_code = get_verification_code()
    await client.sign_up(verification_code, names.get_first_name(), names.get_last_name())

    await client.disconnect()


client.loop.run_until_complete(main())



Traceback

Traceback (most recent call last):
  verification_code = get_verification_code() <- stuck here, since no SMS is being received

The send_code_request is sent successfully, however … no SMS is sent. The phone number is definitely not used … is there something new on the library I had forget?

Thanks in advance!

UPDATE: I double checked the phone number right now with the Telegram App itself … and the Code was sent?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 24 (3 by maintainers)

Most upvoted comments

Please do not publicly share other people’s API IDs and hashes. They should be kept secret. I have edited it with a random hash to prevent abuse.

I have the same problem that when creating an account the SMS or call are not delivered

they use api_id and api_key for detect original telegram or not. i think if we find out original api_id and api_key we succeed. in any case, there is no need to change telethon

I think api_id is one of the parameters due to which it does not want to send SMS. api_id android tg you can search for currentApiId here and see what parameters it additionally sends when connecting I also had an idea to take the jni folder from the android tg and try to replace the connection to the server in the telethon. but so far I have neither knowledge nor time

when i use : api_id = 4 api_hash = '7ebe9e459b40eae77af60cc169e93715'

raised this error: ApiIdPublishedFloodError: This API id was published somewhere, you can't use it now

new report 😃

i de-compile original app and recompile it , but telegram raised error again because they check apk signature. so we need fetch original sign maybe using frida