module auth
function generate_secret_key
Generates a secret key from a Telegram token.
Links: https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app
Args:
token
: Telegram Bot Token
Returns:
bytes
: secret key
class TelegramUser
Represents a Telegram user.
Links: https://core.telegram.org/bots/webapps#webappuser
method __init__
__init__(
id: int,
first_name: str,
is_bot: Optional[bool] = None,
last_name: Optional[str] = None,
username: Optional[str] = None,
language_code: Optional[str] = None,
is_premium: Optional[bool] = None,
added_to_attachment_menu: Optional[bool] = None,
allows_write_to_pm: Optional[bool] = None,
photo_url: Optional[str] = None
) → None
class TelegramAuthenticator
method __init__
method verify_token
Verifies the data using the method from documentation. Returns Telegram user if data is valid.
Links: https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app
Args:
hash_
: hash from init datatoken
: init data from webapp
Returns:
TelegramUser
: Telegram user if token is valid
Raises:
InvalidInitDataError
: if the token is invalid
This file was automatically generated via lazydocs.