LonamiWebs / Telethon

Pure Python 3 MTProto API Telegram client library, for bots too!
https://docs.telethon.dev
MIT License
9.58k stars 1.37k forks source link

RPC login error #3215

Closed jtonkeys1 closed 2 years ago

jtonkeys1 commented 2 years ago

telethon.errors.rpcbaseerrors.AuthKeyError: RPCError 406: UPDATE_APP_TO_LOGIN (caused by SignInRequest)

I am getting this error, anyone know the problem? Ubuntu 20.04 fresh install & can also replicate on macOS

raicg commented 2 years ago

I'm having the same problem, it only happens on the first access, when we are getting a code to login

huisu773 commented 2 years ago

I have a similar problem on Windows 11 and I can also replicate it on Ubuntu 20.04.

telethon.errors.rpcbaseerrors.AuthKeyError: RPCError 406: UPDATE_APP_TO_LOGIN (caused by SendCodeRequest)

It only appears when I try to login with phone number. But there was no problem yesterday.

devRawnie commented 2 years ago

telethon.errors.rpcbaseerrors.AuthKeyError: RPCError 406: UPDATE_APP_TO_LOGIN (caused by SendCodeRequest) Here is the full traceback, on calling client.start()

File "/home/ec2-user/forwardgram/venv/lib64/python3.7/site-packages/telethon/client/auth.py", line 133, in start
    else self.loop.run_until_complete(coro)
  File "/usr/lib64/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/home/ec2-user/forwardgram/venv/lib64/python3.7/site-packages/telethon/client/auth.py", line 189, in _start
    await self.send_code_request(phone, force_sms=force_sms)
  File "/home/ec2-user/forwardgram/venv/lib64/python3.7/site-packages/telethon/client/auth.py", line 515, in send_code_request
    phone, self.api_id, self.api_hash, types.CodeSettings()))
  File "/home/ec2-user/forwardgram/venv/lib64/python3.7/site-packages/telethon/client/users.py", line 30, in __call__
    return await self._call(self._sender, request, ordered=ordered)
  File "/home/ec2-user/forwardgram/venv/lib64/python3.7/site-packages/telethon/client/users.py", line 79, in _call
    result = await future
telethon.errors.rpcbaseerrors.AuthKeyError: RPCError 406: UPDATE_APP_TO_LOGIN (caused by SendCodeRequest)

Facing the same issue on AWS EC2, based on CentOS. This was working fine few hours ago. I got this error, when I opened up a new session, while I had 3 existing sessions already.

atrdev-rgb commented 2 years ago

I have a same problem on Ubuntu 20.04

yaobiao131 commented 2 years ago

Having same issue on windows10

tedmosbious commented 2 years ago

I have same issue Does anyone find a solution?

Lonami commented 2 years ago

The library must be updated. I will try to find time to do so as soon as possible (at least so that login works…). Previous sessions should be okay for a bit longer. Thank you all for your patience.

If you have the same issue, please react with a thumbs-up (πŸ‘) emoji to the original post rather than posting another comment to avoid notifying everyone. I will post updates in this thread.

Telegram has started enforcing the use of 64-bit identifiers for users and chats, and the current stable version of the library does not support them yet. If you try to login, you may see UPDATE_APP_TO_LOGIN error.

I will try to find time to update the library as soon as possible. Although the first version supporting this new layer may not be as well-tested as I would've liked (because I haven't had much time to devote to open source lately). Thank you for your patience.

If you want to stay updated, please subscribe to this GitHub thread.

old fix, read further comments for current solution If someone desperatily needs this fix, please uninstall `telethon` and install either: * https://pypi.org/project/tulir-telethon/ * or `pip3 install git+git://github.com/SpEcHiDe/Telethon@72afe59#egg=telethon` (You may also use a virtual environment.)
Lonami commented 2 years ago

Here are some additional questions people have asked, and the answers:

How does Telegram know if Telethon supports 64-bit IDs or not?

Telegram has a concept known as "layers", allowing old apps to remain working on old layers, and new apps using new layers to enjoy new changes. The current stable version of Telethon has an old layer. Telegram has "split" the layers and left old ones no longer working probably because recent changes have made it very hard to remain backward-compatible (changing user identifiers from 32 to 64 bits is a pretty big change).

After the library updates will the previous session be compatible/usable or will they become invalid?

Previous session files should remain valid (Telethon will still understand them), but it's not possible to know if Telegram will revoke them for other reasons (although it shouldn't).

Does this issue affect bots too?

Yes, bots also need to "login" to work with the API, using a bot token, so they also can get the error.

If I have userbot running, until I restart, it should (probably) be okay?

Existing sessions (and sessions currently in use) should be fine.

Will Telethon add block ads?

The library will not block sponsored messages. Doing so is against Telegram's Terms of Service. If you develop an application using Telethon, you must comply with them, or risk getting your account banned in some way.

If your app allows accessing content from Telegram channels, you must include support for official sponsored messages in Telegram channels and may not interefere with this functionality.

When will a fix be published?

I will try to do this as soon as possible, but because the release will be rushed, bugs may be present. If this is the case, please be sure to report them (or vote if they already exist). For a temporary workaround, please refer to https://github.com/LonamiWebs/Telethon/issues/3215#issuecomment-983368827.

Ghost-147 commented 2 years ago

can this be fixed today please?

LoicRcp commented 2 years ago

Hi

Will we have to modify the codes of all our scripts using Telethon?

Thanks !

Ghost-147 commented 2 years ago

Hi

Will we have to modify the codes of all our scripts using Telethon?

Thanks !

how please?

gnadelwartz commented 2 years ago

Hi

Will we have to modify the codes of all our scripts using Telethon?

Thanks !

no, telethon will take care of compatibility. only if you made stupid assumptions like userd-id will never bigger than 2,147,483,647 you may have to change your script.

truexackep commented 2 years ago

how can I add ads if I use the library as a bot for communicating with user accounts

Lonami commented 2 years ago

I have pushed v1.24 to PyPi, which fixes login (thus avoiding UPDATE_APP_TO_LOGIN), but I have not had the time to test this version thoroughly, so please make sure to report any issues you find here on GitHub.

It contains two more hot-fixes (and the "latest" 133 layer, to prevent receiving broken constructors), but not the latest layer, currently 135, to avoid breaking more things than necessary). Note that if you uninstalled telethon to install the workarounds, you will now need to uninstall the workarounds and install telethon again.

Thank you for your patience and understanding.

Please be aware that this new version uses 64 bit identifier for users, chats, and more. You may need to update your code to handle this correctly.

joaopedrolourencoaffonso commented 2 years ago

1 - Thanks for the work @Lonami! It really helps a lot! 2 - When you release the final new version, could you alert here? So we all update immediately. 3 - About security, there was any meaningfull change?

MADCHEONE commented 2 years ago

I have pushed v1.24 to PyPi, which fixes login (thus avoiding UPDATE_APP_TO_LOGIN), but I have not had the time to test this version thoroughly, so please make sure to report any issues you find here on GitHub...

Thanks for your work!

oliversssss commented 2 years ago

I have pushed v1.24 to PyPi, which fixes login (thus avoiding UPDATE_APP_TO_LOGIN), but I have not had the time to test this version thoroughly, so please make sure to report any issues you find here on GitHub.

It contains two more hot-fixes (and the "latest" 133 layer, to prevent receiving broken constructors), but not the latest layer, currently 135, to avoid breaking more things than necessary). Note that if you uninstalled telethon to install the workarounds, you will now need to uninstall the workarounds and install telethon again.

Thank you for your patience and understanding.

Please be aware that this new version uses 64 bit identifier for users, chats, and more. You may need to update your code to handle this correctly.

Thanks!

Fuze-nl commented 2 years ago

Sadly does not work for me

Lonami commented 2 years ago

@joaopedrolourencoaffonso yes, I can notify about future versions here (if I remember). Regarding security, I'm not sure what you're asking. There have been no security issues that I know of in the previous or current version. You can ask me privately about this if you know something.

@BramGamingNL please make sure you've successfully installed the latest version (verify that print(telethon.__version__) after importing is indeed 1.24).

graysuit commented 2 years ago

Lonami has given solution, but still many folks misread. SOLUTION: Updated: Temporary workaround:

pip uninstall telethon
pip install tulir-telethon

or

pip3 uninstall telethon
pip3 install tulir-telethon
Lonami commented 2 years ago

@graysuit that was only a temporary workaround which is no longer necessary. Updating telethon is enough (and the officially supported way to do it).

netquik commented 2 years ago

Do the new 64-bit identifiers change entity ID and HASH (for people that store them outside code or session file)? If yes will the code break when calling old entities? Thanks

BondarenkoOleksandr commented 2 years ago

When sending the code to the phone, there is no error, but the code does not come, what is my mistake?

Lonami commented 2 years ago

@netquik since an ID never changes, old accounts will still utilize only below 32 bits for their IDs, however, accounts from new users may up to 64 bits (in reality a bit less). The access hash should not be affected for old accounts either.

@BondarenkoOleksandr this seems to not be related to this issue, please see previous issues about that topic, as I believe it's happened and been discussed before.

Fuze-nl commented 2 years ago

Yeah I dont know what you all are saying its still broken. Updating telethon has not worked and I'm already on 1.24

ipkzone commented 2 years ago

thanks @graysuit solved

Fuze-nl commented 2 years ago

didnt work personally

Lonami commented 2 years ago

@BramGamingNL please run the following command on a terminal and make sure it's 1.24.0:

python -c "import telethon; print(telethon.__version__)"

Make sure you use the same Python binary and/or environment as you do when running Telethon.

Fuze-nl commented 2 years ago

Yeah its 1.24.0.

Lonami commented 2 years ago

Please open a new issue with the full error traceback and commit you're using.

graysuit commented 2 years ago

@graysuit that was only a temporary workaround which is no longer necessary. Updating telethon is enough (and the officially supported way to do it).

@Lonami Thanks. But I didn't understand why issue isn't closed yet, if it resolved in latest telethon package ?

skate4lol commented 2 years ago

mabye cuz it doesnt work for everyone..... i did update&upgrade deleted old telethon and installed latest and it didnt work, not even the temporary fix

joaopedrolourencoaffonso commented 2 years ago

@graysuit that was only a temporary workaround which is no longer necessary. Updating telethon is enough (and the officially supported way to do it).

@Lonami Thanks. But I didn't understand why issue isn't closed yet, if it resolved in latest telethon package ?

Actually there still the whole thing with the sponsored messages plus any unseen bugs that might emerge in the next weeks.

skate4lol commented 2 years ago

can anyone help me with this issue? still cant solve it

Fuze-nl commented 2 years ago

Same, not going to open a new one as its the same issue kek

gnadelwartz commented 2 years ago

Same, not going to open a new one as its the same issue kek

as it's working for other's including me, more information is needed to find out why it's nor working for you this is why lonami asking for a new issue with traceback etc.

without this you may wait forever for a solution.

Fuze-nl commented 2 years ago

Yeah i posted it

RobiMez commented 2 years ago

doing pip install telethon --update solved it for me

Fuze-nl commented 2 years ago

pip install telethon --update

no such option: --update

netquik commented 2 years ago

pip install -U telethon (-U should be --upgrade in short and is command of install so must be used after install) first be sure to use new version 1.2.4 you will see something like this if you use wheel Downloading Telethon-1.24.0-py3-none-any.whl

Fuze-nl commented 2 years ago

Yeah I already did that, "already satatisfied"

Lonami commented 2 years ago

Maybe you need to use --no-cache?

Fuze-nl commented 2 years ago

What does that do? it gives me '--no-cache' is not recognized as an internal or external command, operable program or batch file.

Lonami commented 2 years ago

Sorry I didn't make myself clear. It's a flag you have to add to your pip command (the one you use when upgrading Telethon).

graysuit commented 2 years ago

What does that do? it gives me '--no-cache' is not recognized as an internal or external command, operable program or batch file.

@BramGamingNL not just --no-cache, but pip install -U telethon --no-cache

netquik commented 2 years ago

Yeah I already did that, "already satisfied" @BramGamingNL Well if your are sure to have new Telethon==1.24.0 (pip freeze) and that you are working in the same environment where you did the upgrade, you should probably explain further the errors you are getting, and more details about your code (for example if your code is requiring a specific version of telethon, if you are compiling it, or the environment of your project)

Fuze-nl commented 2 years ago

What does that do? it gives me '--no-cache' is not recognized as an internal or external command, operable program or batch file.

@BramGamingNL not just --no-cache, but pip install -U telethon --no-cache

deleted and then got this

C:\Users\Bram>pip install -U telethon --no-cache Collecting telethon Downloading Telethon-1.24.0-py3-none-any.whl (528 kB) |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 528 kB 6.4 MB/s Requirement already satisfied: rsa in c:\users\bram\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from telethon) (4.8) Requirement already satisfied: pyaes in c:\users\bram\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from telethon) (1.6.1) Requirement already satisfied: pyasn1>=0.1.3 in c:\users\bram\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from rsa->telethon) (0.4.8) Installing collected packages: telethon Successfully installed telethon-1.24.0

Lonami commented 2 years ago

Does it work now?

Fuze-nl commented 2 years ago

Holy fucking shit, thank you guys for trying to help but I found the issue. I had 2 pythons installed. I deleted 3.7 and 3.10 works. Thanks dudes

fernvenue commented 2 years ago

I just solved this issue by: python3 -m pip install --upgrade telethon