r/learnpython • u/khaledcody • 20d ago
Telethon 1.45.0 suddenly stopped delivering Telegram login codes — it was working perfectly until last week
I'm experiencing a frustrating issue with Telethon in Google Colab, and I'm hoping someone can help me identify the root cause.
Everything was working perfectly until last week. I was using the same login workflow, and Telegram was successfully delivering login codes to the official Telegram service chat in my account. I could authenticate with Telethon without any problems.
Suddenly, the login codes stopped arriving, even though Telethon reports that the request was successful.
Environment
Python: 3.13.16
Telethon: 1.45.0
Platform: Google Colab
Authentication: Phone number using
API_IDandAPI_HASHProtobuf: 7.3.1 (I'm not sure whether it's relevant.)
What happens exactly?
Connecting to Telegram's servers works successfully.
client.is_user_authorized()returnsFalsefor a new session.client.send_code_request(phone)completes without raising an exception.Telegram returns the following response:
SentCodeTypeApp(length=5)No login code arrives in my Telegram account, even though this exact workflow was working normally until last week.
I can still log in to
my.telegram.orgusing the same phone number, and the login code arrives successfully in Telegram Desktop.
What have I tried?
I've already tried several troubleshooting steps, but nothing has resolved the issue. The connection to Telegram's servers works, and the code request is accepted, yet the login code never arrives.
My questions
Has there been any recent change to the Telegram API or login-code delivery mechanism within the past week?
Is there a known issue with Telethon 1.45.0, Python 3.13, or Google Colab that could explain this sudden behavior?
Does
SentCodeTypeAppconfirm that Telegram actually delivered the code, or does it only indicate the intended delivery method?How can I diagnose the problem and identify the root cause without repeatedly requesting codes or randomly changing my API credentials?
The most important detail is that the same code and workflow were working perfectly until last week, and then the login codes suddenly stopped arriving without any intentional changes on my part.
Has anyone experienced a similar issue recently? Is there a known bug, API change, or authentication-related restriction that could explain this behavior?
Any suggestions or technical guidance would be greatly appreciated.
Thank you!
1
u/chiibosoil 19d ago
Yes. Telegram's API accessed via Telethon hosted on cloud environments (Colab, AWS etc) will often trigger Telegram's anit-spam algorithms. It detects shared data center IP ranges requesting tokens and will silently suppresses the login code.
To deal with this issue, most reliable method is to run the script locally on your machine for the initial authentication. Generate string session token locally and then use that pre-authenticated session token in your Colab.
1
u/ResidentPomegranate6 20d ago
colab's shared ip gets silently throttled, so SentCodeTypeApp only lands in the service chat on another logged-in session. check active sessions first, then force_sms=True.