Code Monkey home page Code Monkey logo

Comments (8)

alexander-akhmetov avatar alexander-akhmetov commented on June 19, 2024

Hi,

On which authorisation state does it fail? It should print it to the logs.

from python-telegram.

CatCoderr avatar CatCoderr commented on June 19, 2024

I have the same problem, here is logs: https://pastebin.com/qAUQr5Ck

from python-telegram.

alexander-akhmetov avatar alexander-akhmetov commented on June 19, 2024

I see, thanks for the logs. Probably it's related to the encryption key (parameter database_encryption_key).

While it's not fixed in python-telegram, can you try to make the database encryption key string longer? Probably you'll need to remove existing tdlib database. By default python-telegram keeps it in /tmp/.tdlib_files/

tg = Telegram(
    database_encryption_key='...',
)

from python-telegram.

steven-chau avatar steven-chau commented on June 19, 2024

I have the exact same problem! Same error. Same stacktrace.

I have tried a long database_encryption_key and a short one. No luck :(

Perhaps the protocol has changed? The underlying tdLib library needs to be upgraded?

from python-telegram.

jonasborges avatar jonasborges commented on June 19, 2024

I see, thanks for the logs. Probably it's related to the encryption key (parameter database_encryption_key).

While it's not fixed in python-telegram, can you try to make the database encryption key string longer? Probably you'll need to remove existing tdlib database. By default python-telegram keeps it in /tmp/.tdlib_files/

tg = Telegram(
    database_encryption_key='...',
)

It seems to be the parameter name being sent.

The example provided by tdlib uses key as parameter for checkDatabaseEncryptionKey messages.

{'@type': 'checkDatabaseEncryptionKey', 'key': '...'}

While python-telegram is using encryption_key.
The documentation also mention encryption_key.

So, I made it work by changing the key name from encryption_key to key. I'm not sure if this is the proper solution but works for now.

from python-telegram.

alexander-akhmetov avatar alexander-akhmetov commented on June 19, 2024

The example provided by tdlib uses key as parameter for checkDatabaseEncryptionKey messages.

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 encryption_key has type bytes and in the documentation it is string. They mentioned in one of the issues that bytes should be sent as base64 encoded string. The error original error message (Wrong padding length) is also related to base64.

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 base64 and difference between key and encryption_key: tdlib/td#970


Can somebody try to use the default key from the python-telegram examples (database_encryption_key='changeme1234') and an empty key (database_encryption_key=''), please?

from python-telegram.

alexander-akhmetov avatar alexander-akhmetov commented on June 19, 2024

I asked a question in tdlib repository about base64 and difference between key and encryption_key: tdlib/td#970

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,
)

from python-telegram.

alexander-akhmetov avatar alexander-akhmetov commented on June 19, 2024

Released 0.12.0 (both the package and the docker image), if you still see the problem, please re-open the issue

from python-telegram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.