Python client for Telegram Gateway verification API
Project description
telegram-gateway-verification
Python-библиотека для отправки кодов верификации через Telegram Gateway API.
Возможности
- Отправка кода верификации (
sendVerificationMessage) - Проверка возможности отправки (
checkSendAbility) - Проверка статуса верификации (
checkVerificationStatus) - Отмена отправленного запроса (
revokeVerificationMessage) - Проверка подписи webhook callback (
X-Request-Timestamp,X-Request-Signature)
Установка
pip install telegram-gateway-verification
Установка для локальной разработки:
pip install -e '.[dev]'
Быстрый старт
import os
from telegram_gateway_verification import TelegramGatewayClient
client = TelegramGatewayClient(
api_token=os.environ["TELEGRAM_GATEWAY_TOKEN"], #https://gateway.telegram.org/account/api
)
status = client.send_verification_message(
phone_number="+15551234567",
code_length=6,
ttl=60,
callback_url="https://example.com/webhooks/telegram-gateway",
)
print(status.request_id)
API
send_verification_message(...) -> RequestStatus
check_send_ability(phone_number=...) -> RequestStatus
check_verification_status(request_id=..., code=...) -> RequestStatus
revoke_verification_message(request_id=...) -> bool
Проверка подписи callback
from telegram_gateway_verification import verify_callback_signature
ok = verify_callback_signature(
api_token=os.environ["TELEGRAM_GATEWAY_TOKEN"],
timestamp_header=request.headers["X-Request-Timestamp"],
signature_header=request.headers["X-Request-Signature"],
raw_body=request.get_data(), # raw bytes тела запроса
)
if not ok:
return "invalid signature", 403
Важные детали
phone_numberдолжен быть в формате E.164 (например,+15551234567).ttlдляsendVerificationMessage: от30до3600секунд.- Если API отвечает
{"ok": false, ...}, библиотека бросаетTelegramGatewayAPIError.
Полезные ссылки
- Telegram Gateway API: https://core.telegram.org/gateway/api
- Telegram Gateway Overview: https://core.telegram.org/gateway
- Verification Tutorial: https://core.telegram.org/gateway/verification-tutorial
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file telegram_gateway_verification-0.1.1.tar.gz.
File metadata
- Download URL: telegram_gateway_verification-0.1.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64da2feceaf5389e65fc5f95f103c9b1a807c9689eae96fbb5e7407488cc702c
|
|
| MD5 |
dca1a86f232277f7880bc75b49c49525
|
|
| BLAKE2b-256 |
d6e1af247b2ae995b2765721e89e360885f46dfff985aafbf795f20e36221e72
|
File details
Details for the file telegram_gateway_verification-0.1.1-py3-none-any.whl.
File metadata
- Download URL: telegram_gateway_verification-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9ff88f15f2dacbe2db21e6fc449b4a92525e3ef27481e4a931ecc6dce496760
|
|
| MD5 |
4528fb7d8047a9f99da646cd9db567e5
|
|
| BLAKE2b-256 |
e1a6094841930e0512329e1bd108d94ee1ed48748eddaff237cec53f78d07816
|