Emad Helmi
Emad Helmi

Reputation: 695

AuthKeyDuplicatedError telethon

With the code below I have been connected to the telegram using telethon for about one year!

client = TelegramClient(
        SESSION,
        API_ID,
        API_HASH
    )
client.connect()
# the rest of my code

Yesterday when I want to connect to my session with the code I got this error:

telethon.errors.rpcerrorlist.AuthKeyDuplicatedError: An auth key with the same ID was already generated

The error does not tell anymore and in the doc there is no more description about this error message. How can I retrieve my session?

Upvotes: 5

Views: 8802

Answers (1)

tashakori
tashakori

Reputation: 2441

one of the ways to produce this error is to run 2 instances of the same session in separate locations simultaneously(or at least with a small difference in their connection time to TG)

if you have access to those phone numbers(or any other active sessions of them e.g. Android app), you can do the below procedure, otherwise as far as I know, I afraid that you can't do anything for other compromised clients that you don't have access to their numbers(or any other active sessions in other applications):

First, make sure that no Telethon session instances are running on your server(s)(at least for those you have access to). Second, you can kill that session manually(in "active session" part of telegram applications e.g. Android). third, delete ".session" files from your server. fourth, sign in to your client in the server again.

Upvotes: 4

Related Questions