Telethon Authorization. All sessions are reset after authorization

Joined
Aug 7, 2025
Messages
1
Reaction score
0
I have a problem with a Python script using the telethon library - all sessions are reset after authorization. The script can authorize users in two ways: code in the telegram application or
qr-code. For authorization via code, the phone number and user code received in the application are used, as well as the api_id and api_hash common to all. In this case, two-factor authentication is taken into account by substituting the user’s password. As a result, the user adds another device to the telegram application. After successful authorization, on some accounts after a while (about a minute) there is a crash from all sessions and I do not understand why. On other accounts, there are no problems after authorization, you can connect any number of devices. I noticed that on the account on which the crash from all sessions occurs, mail for authorization is installed (we are talking specifically about the mail for authorization, and not for the mail that is used to install and reset two-factor authentication). At the same time, on other accounts, mail cannot be added in any way. I found information that telegram itself decides whether the email should be linked to the account or not. Is it possible that telegram also requires confirmation via email, but we don’t see it anywhere? In telethon, there is no way to force the confirmation code to be sent to email, moreover, after calling send_code_request(phone), auth.SentCodeTypeApp is always returned, which means that the code will only come to the application itself. I experimented with sessions, saved both to a file and as a string, but nothing helps.

Has anyone encountered a similar session crash? Can the presence of email affect the reset of sessions, or can it depend on something else? Maybe there is a solution to this problem in other programming languages?

I use Python 3.9.2, telethon 1.40.0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,344
Messages
2,571,432
Members
48,794
Latest member
massivestack

Latest Threads

Top