LonamiWebs / Telethon

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

telethon.errors.rpcerrorlist.PasswordHashInvalidError: The password (and thus its hash value) you entered is invalid #1029

Closed masoudcom closed 5 years ago

masoudcom commented 6 years ago

Hi. When use edit_2fa for first time, get error telethon.errors.rpcerrorlist.PasswordHashInvalidError! telethon version is : 1.3

masoudcom commented 6 years ago

verbose: File "", line 1, in File "/home/uroot/.local/lib/python3.6/site-packages/telethon/sync.py", line 35, in syncified else asyncio.get_event_loop().run_until_complete(coro) File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete return future.result() File "/home/uroot/.local/lib/python3.6/site-packages/telethon/client/auth.py", line 470, in edit_2fa current_password_hash, new_settings=new_settings File "/home/uroot/.local/lib/python3.6/site-packages/telethon/client/users.py", line 60, in call result = await future telethon.errors.rpcerrorlist.PasswordHashInvalidError: The password (and thus its hash value) you entered is invalid

Lonami commented 6 years ago

Aw, too bad there's people actually interested in the feature. That makes me have less reasons to remove the function altogether. Although compatibility was enough reason to keep it. Telegram has probably changed things server-side and, although the library is using the right method, it's calculating it incorrectly. You see:

https://github.com/LonamiWebs/Telethon/blob/4562ba9ccfb1aef33facd5ca1a2675705d390e1c/telethon/client/auth.py#L474-L485

And if we look at the schema.tl for the current layer:

https://github.com/LonamiWebs/Telethon/blob/4562ba9ccfb1aef33facd5ca1a2675705d390e1c/telethon_generator/data/telegram_api.tl#L947

https://github.com/LonamiWebs/Telethon/blob/4562ba9ccfb1aef33facd5ca1a2675705d390e1c/telethon_generator/data/telegram_api.tl#L1185

So currently the library is stuck at layer 82 because layer 86 has added some new stuff regarding passwords… And I don't have enough interest in making it work myself. Technically, it's possible to read on how tdesktop does it, and eventually we should do that.

TL; DR; would be nice if someone could invest some of their time into porting the new way of working with passwords to Telethon, from tdesktop or any other implementation.

Kyle2142 commented 6 years ago

I suspect you set current_password to some non-None value. Please show us what your function call looked like

masoudcom commented 6 years ago

client.edit_2fa(new_password='mser', hint='Reg')

Kyle2142 commented 6 years ago

Thank you for the reply, however: image Can not reproduce... Perhaps the method only works for people who have used it prior to the new layer? Side note: I am the one who made (well, ported) the original function in telethon and I apologize for not having the energy to implement the new one.

Lonami commented 5 years ago

Closed since the new edit_2fa exists and has been tested.