Last active
June 30, 2024 10:20
-
-
Save nuhmanpk/5b2b29fcecd479754c599c36c0961363 to your computer and use it in GitHub Desktop.
Generate Pyrogram Session string using Bot token or Phone Number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyrogram import Client | |
# get these values from api.telegram.org | |
api_id = "API_ID" | |
api_hash = "API_HASH" | |
async def main(): | |
async with Client(":memory:", api_id=int(api_id), api_hash=api_hash) as app: | |
# Generate the session string | |
session_string = await app.export_session_string() | |
print("Your session string is:", session_string) | |
if __name__ == "__main__": | |
import asyncio | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create a venv and install pyrogram and tgcrypto, then replace the api_id and api_hash with your credentials .