The TDataSession.from_tdata() method currently ignores the API credentials (api_id, api_hash, device_model, etc.) stored in the tdata folder and instead uses the default API.TelegramDesktop values.
Current Behavior:
@classmethod
def from_tdata(cls, tdata_folder: Union[Path, str]):
tdata_folder = Path(tdata_folder)
if not tdata_folder.exists():
raise FileNotFoundError(tdata_folder)
client = TDesktop(basePath=tdata_folder)
account = client.mainAccount
return cls(
auth_key=account.authKey.key,
user_id=account.UserId,
dc_id=account.MainDcId
# api parameter is not passed, so default API.TelegramDesktop is used
)
Expected Behavior:
The method should extract and use the actual API credentials from the tdata folder via client.api:
return cls(
auth_key=account.authKey.key,
user_id=account.UserId,
dc_id=account.MainDcId,
api=client.api # Use actual API from tdata
)
Impact:
When converting tdata sessions to Pyrogram/Telethon, the resulting session uses incorrect API credentials, which can cause:
- Authentication failures
- API ID mismatches with the original session
- Potential account restrictions
Workaround:
Manually create SessionManager with correct API:
desk = TDesktop(str(tdata_path))
session_manager = SessionManager(
dc_id=desk.mainAccount.MainDcId,
auth_key=desk.mainAccount.authKey.key,
user_id=desk.mainAccount.UserId,
api=desk.api
)
The
TDataSession.from_tdata()method currently ignores the API credentials (api_id,api_hash,device_model, etc.) stored in the tdata folder and instead uses the defaultAPI.TelegramDesktopvalues.Current Behavior:
Expected Behavior:
The method should extract and use the actual API credentials from the tdata folder via
client.api:Impact:
When converting tdata sessions to Pyrogram/Telethon, the resulting session uses incorrect API credentials, which can cause:
Workaround:
Manually create
SessionManagerwith correct API: