-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Failed to parse JSON object as TDLib request: Wrong padding length" When tried to login #81
Comments
Hi, On which authorisation state does it fail? It should print it to the logs. |
I have the same problem, here is logs: https://pastebin.com/qAUQr5Ck |
I see, thanks for the logs. Probably it's related to the encryption key (parameter While it's not fixed in tg = Telegram(
database_encryption_key='...',
) |
I have the exact same problem! Same error. Same stacktrace. I have tried a long Perhaps the protocol has changed? The underlying |
It seems to be the parameter name being sent. The example provided by tdlib uses key as parameter for {'@type': 'checkDatabaseEncryptionKey', 'key': '...'} While python-telegram is using encryption_key. So, I made it work by changing the key name from |
Hm, interesting! I'm not sure if it's a mistake or they are interchangeable. I will try to look into that. I also found that in td_api.tl With base64 encoded string it seems to be working, but I don't know yet how to check if tdlib is using the correct and decoded from base64 key, or just the passed string: def _send_encryption_key(self) -> AsyncResult:
logger.info('Sending encryption key')
key = self._database_encryption_key
if isinstance(key, str):
key = key.encode()
data = {
'@type': 'checkDatabaseEncryptionKey',
'encryption_key': base64.b64encode(key).decode(),
}
return self._send_data(data, result_id='updateAuthorizationState') I asked a question in tdlib repository about Can somebody try to use the default key from the python-telegram examples ( |
Yes, it has bytes type and should be encoded using base64, I'll make changes to python-telegram. While it's not fixed, you can try to do it on your side: use a different key with a different length or encode encryption key using base64 and pass it to Telegram: import base64
...
encryption_key = base64.b64encode(b'secret').decode()
tg = Telegram(
...
database_encryption_key=encryption_key,
) |
…tion-key Fix #81 Encode database encrypting key using base64
Released |
File "/app/index.py", line 17, in
tg.login()
File "/usr/local/lib/python3.8/site-packages/telegram/client.py", line 439, in login
result.wait(raise_exc=True)
File "/usr/local/lib/python3.8/site-packages/telegram/utils.py", line 41, in wait
raise RuntimeError(f'Telegram error: {self.error_info}')
RuntimeError: Telegram error: {'@type': 'error', 'code': 400, 'message': 'Failed to parse JSON object as TDLib request: Wrong padding length', '@extra': {'request_id': 'updateAuthorizationState'}}
Code is running in docker!
Thank you
The text was updated successfully, but these errors were encountered: