Telegram Auth Backend for FastAPI/Starlette
INSTALL
In your FastAPI/Starlette app:
pip install xtg-auth
Add your Telegram Bot API Token to .env file as TgBotToken:
TgBotToken=0000000000:AAaaaAaAAAaaAAAAaaAAAaAAAaaAaaaaaAA
Before running add AuthenticationMiddleware to your app, and set TgAuth object with passed token as backend
from fastapi import FastAPI
from starlette.middleware.authentication import AuthenticationMiddleware
from tg_ath import TgAuth
app = FastAPI()
TOKEN = env('TgBotToken')
app.add_middleware(AuthenticationMiddleware, backend=TgAuth(TOKEN))
Using:
Protected endpoints expect Telegram.WebApp.initData string in Authorization header afrer Tg prefix in each request.
example:
Authorization: Tg user=%7B%22id%22%3A1038938370%2C%22first_name%22%3A%22Crypto%E2%86%94%EF%B8%8FFiat%22%2C%22last_name%22%3A%22%F0%9F%92%B5%F0%9F%92%B6%F0%9F%92%B3%22%2C%22username%22%3A%22ex212%22%2C%22language_code%22%3A%22en%22%2C%22allows_write_to_pm%22%3Atrue%7D&chat_instance=-6786124926491770465&chat_type=sender&auth_date=1729138692&hash=32e367eb6019007fdb2bd8f9a08628fb14ebc737df4a0dad3ecd2910b342f488
Metadata
Release files for xtg-auth 0.0.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xtg_auth-0.0.19.tar.gz | 5.3 kB | Without provenance | Details for xtg_auth-0.0.19.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xtg_auth-0.0.19-py3-none-any.whl | Python 3 | none | any | Details for xtg_auth-0.0.19-py3-none-any.whl |
Total release size: 10.2 kB
Release files / xtg_auth-0.0.19.tar.gz
| Download URL | xtg_auth-0.0.19.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e990b48b802cf4e67e380efb4cc8dfe2438ea5c095214ced18c3b2e677faca33
|
|
BLAKE2b-256 checksum How to use checksums |
6207a50e936846ad90d290be3875a8481fb15691ca934b921e215ccd19defbe9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.9
|
Release files / xtg_auth-0.0.19-py3-none-any.whl
| Download URL | xtg_auth-0.0.19-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1dac0eff3c9a4d5cabdc626902a5a767db66c5c6864a196a2123e11f241a5fc7
|
|
BLAKE2b-256 checksum How to use checksums |
f71d0b1732e3bee497f88aae0ddb566955a88af0b3913a5c6b861571f5495b0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.9
|
Security for xtg-auth 0.0.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.