Search code examples
c#.netwinformstelegram-apiwtelegramclient

Telegram Logout Active Session : Account_GetAuthorizations return 0 hash for active session


I Use Wtelegram Client I Need Get All Active Session With This Code Ok C# Code

Account_Authorizations getsession = Task.Run(async () => await clienttelegram2.Account_GetAuthorizations()).Result;

But I Want Get Session Hash Of My Active Session Return Zero :

foreach (TL.Authorization item in getsession.authorizations) { if (item.api_id == XXXXXXX) { bool logoutok = Task.Run(async () => await clienttelegram2.Account_ResetAuthorization(item.hash)).Result; break; } }

Please See Screen Shot of My Code Screen Shot of My Code

Thx For Reading MY Problem .


Solution

  • The current active session (see flags "current" on your screenshot) has a zero hash because it cannot be terminated in this way.

    • Auth_ResetAuthorizations() is used to terminate all devices/sessions, except the current one
    • Account_ResetAuthorization(hash) is used to terminate another specific device/session based on its hash
    • Auth_LogOut() is used to terminate the current session

    "Terminate" means that device/session is forced to logout from the current user account.