opentele icon indicating copy to clipboard operation
opentele copied to clipboard

switching from .session to tdata not working

Open vnpresent opened this issue 2 years ago • 4 comments

I tried it, although it creates a folder tdata but there is no login on it

vnpresent avatar Mar 14 '22 13:03 vnpresent

It's still working for the latest version of Telegram Desktop. Can you post your code here and also specify which version of Telegram Desktop you're using?

Edit: Please make sure that you have the latest version of opentele

pip install -U --no-cache-dir opentele

thedemons avatar Mar 15 '22 09:03 thedemons

I run the code from the example and raises an error...

from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, UseCurrentSession
import asyncio
import os

async def main():
    client = TelegramClient('62895385923488.session')
    tdesk = await client.ToTDesktop(flag=UseCurrentSession)   # error occurs here
    tdesk.SaveTData()#"tdata")

asyncio.run(main())

-----------------------------------------------
File "/home/af/.local/lib/python3.9/site-packages/opentele/td/account.py", line 1007, in FromTelethon
    Expects(
opentele.exception.TelethonUnauthorized: TelethonUnauthorized: Telethon client is unauthorized, it need to be authorized first [ Called by FromTelethon() ]

how to make it work?

Alex6447 avatar Mar 24 '22 16:03 Alex6447

I run the code from the example and raises an error...

from opentele.td import TDesktop
from opentele.tl import TelegramClient
from opentele.api import API, UseCurrentSession
import asyncio
import os

async def main():
    client = TelegramClient('62895385923488.session')
    tdesk = await client.ToTDesktop(flag=UseCurrentSession)   # error occurs here
    tdesk.SaveTData()#"tdata")

asyncio.run(main())

-----------------------------------------------
File "/home/af/.local/lib/python3.9/site-packages/opentele/td/account.py", line 1007, in FromTelethon
    Expects(
opentele.exception.TelethonUnauthorized: TelethonUnauthorized: Telethon client is unauthorized, it need to be authorized first [ Called by FromTelethon() ]

how to make it work?

The error is:

TelethonUnauthorized: Telethon client is unauthorized, it need to be authorized first

Your .session file is not authorized yet, that mean you haven't logged in.

thedemons avatar Mar 24 '22 16:03 thedemons

Everything miraculously worked after your answer. Thanks! But now I don't understand why it didn't work...

This is your code from account.py :

..........
else:
            copy = telethonClient

ss = copy.session
authKey = ss.auth_key.key
dcId = DcId(ss.dc_id)
userId = copy.UserId
authKey = td.AuthKey(authKey, td.AuthKeyType.ReadFromFile, dcId)

if userId == None:
    await copy.connect()
    await copy.get_me()
    userId = copy.UserId  # the problem was here
..........

copy.UserId was returning None. I do not understand why I did not connect with the client? Now everything connects and gets the userId. I am now going to use your library. Suddenly I have questions, let me disturb you in telegrams? For efficiency ... My telegram @AlexFX77

I'm sorry for my English, I'm using google translate...

Alex6447 avatar Mar 27 '22 08:03 Alex6447