Telegram authentication library
Project description
Telegram WebApp Auth Library
This library is a simple way to authenticate users in your web application using Telegram.
Installation
Using pip
pip install teleapp-auth
Using Poetry
poetry add teleapp-auth
Using pipenv
pipenv install teleapp-auth
Using uv
uv pip install teleapp-auth
Usage
from fastapi import Request, FastAPI
from teleapp_auth import get_secret_key, parse_webapp_data, validate_webapp_data
app = FastAPI()
secret_key = get_secret_key("BOT_TOKEN")
@app.post("/check_data")
async def check_data(request: Request) -> bool:
request_json = await request.json()
auth_data = request_json.get("auth_data") # Telegram auth data from the webapp
webapp_data = parse_webapp_data(auth_data) # Parse the auth data to dict
# Example of the parsed data:
# WebAppInitData {
# query_id: "AAEt6-JYAAAAAC3r4lj2oADQ",
# user: WebAppUser {
# id: 1491266349,
# is_bot: None,
# first_name: "Test",
# last_name: "",
# username: "test",
# language_code: "ru",
# is_premium: None,
# added_to_attachment_menu: None,
# allows_write_to_pm: true,
# photo_url: None
# },
# receiver: None,
# chat: None,
# chat_type: None,
# chat_instance: None,
# start_param: None,
# can_send_after: None,
# auth_date: 1726572911,
# hash: "f87a5a37a5b487700a35cb1e3d2e92afa67e4b67066c9f1fa2c34986c2350b6e
# }
return validate_webapp_data(webapp_data, secret_key) # True if the data is valid, False otherwise
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
teleapp_auth-1.0.0.tar.gz
(9.4 kB
view hashes)
Built Distributions
Close
Hashes for teleapp_auth-1.0.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 618c941765eb89f5ef06361143c405fee0a3f35046b3d29e74d1f2aadcabf379 |
|
MD5 | 6673edb7c191bd30b30dab049b33dbc5 |
|
BLAKE2b-256 | 920c7351b6ab9ac42b508a2bca37896c5bdb85978a561f760b41db9eb4610591 |
Close
Hashes for teleapp_auth-1.0.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75db48818059be34bc6167128777de4441ce0316452c63bea4964805c40069af |
|
MD5 | 64d6b62621b01e1d5135b74535adea95 |
|
BLAKE2b-256 | 3874de71596484dc0e17128c2616bba3a168d4cd72afb6abbdf4f28c2bbb7d50 |
Close
Hashes for teleapp_auth-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c32b4eea693175223856ebb4c36e8fd47d45cfc84078e35f59f8c184200dee65 |
|
MD5 | de43540207d9a6aa76e59762fefcb770 |
|
BLAKE2b-256 | 799049f03f315dcb1d21c6574c043fb15e976361b8286d157b1e075d31c550ab |
Close
Hashes for teleapp_auth-1.0.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d0ffbb0f9abf3aaa74b3dbedf5a00da72611935dc49dadd7ab4da706df9bf4d |
|
MD5 | d3d1dd3a81282bce19995f524fccb200 |
|
BLAKE2b-256 | 58c616743865087f442d1a9b4222aef52c3f9fae53570df0ed2fbd7a1eb29c2c |
Close
Hashes for teleapp_auth-1.0.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 895b02eab1af72d6416a6482996962cc4ea4362b17a2610eba76918cb13feb3f |
|
MD5 | 98bd17b3c7928dd37b2bfca155e059dc |
|
BLAKE2b-256 | c1bd20f01eb60d970b8702768889cbbb27151a95b321d2c5ca9b1faff224f0aa |
Close
Hashes for teleapp_auth-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f2b42ed5ef2b69168bcf0185624ce8bfd0007e9e54f5a0026be058124e5b30 |
|
MD5 | 94e247459ea0410f6c313b203e95f4c6 |
|
BLAKE2b-256 | 21fb0da5f11f2c6776a308aef63c11c58f1ad452c40282921241b358586b6036 |
Close
Hashes for teleapp_auth-1.0.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeba469714032d0dec4c0b4645748b575b3120c3428f7419b0c1941f381a1c70 |
|
MD5 | 77ff5400e1091962dd82b3841e7b0e92 |
|
BLAKE2b-256 | 724a6193421cc2954b395c297f5b950fe33f50a0fab6088ccffde2bb3da3a357 |
Close
Hashes for teleapp_auth-1.0.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 541ff0b8ce43b44f7bf9b7ae1563a734e9e1e817e67d9c714a179023a56f400c |
|
MD5 | dd33505c0650b1a9f32f94d878067e73 |
|
BLAKE2b-256 | 05cbc742613275207e335388e0d3e77e2ef14f13b1e3fa89b998d8a7b8d7f04c |
Close
Hashes for teleapp_auth-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45eb936569c38331f89bd235bf41ffe84eab81a03dff8321a6961401fa43f0c1 |
|
MD5 | 29d60a3952b74837ec1356cfe9e6639d |
|
BLAKE2b-256 | 4bed1f8a48a03764117cc8d36f85df7f407da0f0c51560f982b03f551a968774 |
Close
Hashes for teleapp_auth-1.0.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ef30298bace37bee4f12fa962f9d6fb86a3543f8039930312f2d45b656c6bf6 |
|
MD5 | 89b19e2662de3c91a4b40e0673d6fd84 |
|
BLAKE2b-256 | e4f9ba44cc30a16679083cc7876a946a971563ae184aa0975206398b70809c4c |
Close
Hashes for teleapp_auth-1.0.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bbb6098d5f2c99ed6d17f8b9be4f6eb5b0e44bc122131a4cf26610fca76cb89 |
|
MD5 | 38a1e2bf3bd3591a09f4647ba446ec1a |
|
BLAKE2b-256 | cceb5918307e471d63615e55f0b141ab4d873ac3c86826af6be079251b0d06c5 |
Close
Hashes for teleapp_auth-1.0.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9268d86cf6c5384033b5af735c49dabe755f7afb514a9f863205903114ff1c4b |
|
MD5 | 0c496987fb8720f5ceb8420f4718da43 |
|
BLAKE2b-256 | 3d7d33e9d2ce0e4561593fb40b455ca1faee0589ca99e77d73b6c61ec7aa130e |