Unlike the Telegram Bot API, the Telegram Client API requires an access_hash to interact with channels, users, and other entities. Using only an ID will result in errors like CHANNEL_INVALID or USER_ID_INVALID.
An access_hash is a proof that the logged-in user is authorized to access that specific resource.
How to obtain an access_hash:
Obtain description structures (such as Channel, User, Photo, or Document) through:
- Receiving updates.
- Querying API methods like
Messages_GetAllDialogs or Contacts_ResolveUsername. - Using helper methods like
UserOrChat or CollectUsersChats.
How to use it in API calls:
When calling an API method that requires an Input... structure (like InputPeer, InputChannel, or InputUser):
- Recommended: Pass the description structure (e.g., the
User or Channel object) directly. The library uses implicit conversion operators to automatically create the required Input... structure. - Manual: Extract the
access_hash from the description structure and manually construct the Input... object.