Auth Widget

Implementation of Telegram site authorization checking mechanism for more information https://core.telegram.org/widgets/login#checking-authorization

Source: https://gist.github.com/JrooTJunior/887791de7273c9df5277d2b1ecadc839

aiogram.utils.auth_widget.generate_hash(*args, **kwargs) → str[source]

Generate secret hash

Parameters
  • data

  • token

Returns

aiogram.utils.auth_widget.check_token(*args, **kwargs) → bool[source]

Validate auth token

Parameters
  • data

  • token

Returns

aiogram.utils.auth_widget.check_signature(token: str, hash: str, **kwargs) → bool[source]

Generate hexadecimal representation of the HMAC-SHA-256 signature of the data-check-string with the SHA256 hash of the bot’s token used as a secret key

Parameters
  • token

  • hash

  • kwargs – all params received on auth

Returns

aiogram.utils.auth_widget.check_integrity(token: str, data: dict) → bool[source]

Verify the authentication and the integrity of the data received on user’s auth

Parameters
  • token – Bot’s token

  • data – all data that came on auth

Returns