Skip to content

Commit 4adec92

Browse files
CopilotnijelCopilot
authored
Add Telegram backend documentation (#357)
* Initial plan * Add Telegram backend documentation Co-authored-by: nijel <[email protected]> * Update docs/backends/telegram.rst Co-authored-by: Copilot <[email protected]> * Update docs/backends/telegram.rst Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: nijel <[email protected]> Co-authored-by: Michal Čihař <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 0a7a4b3 commit 4adec92

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

docs/backends/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ Social backends
169169
strava
170170
stripe
171171
taobao
172+
telegram
172173
thisismyjam
173174
trello
174175
tripit

docs/backends/telegram.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Telegram
2+
========
3+
4+
Telegram uses a widget-based authentication method for login.
5+
6+
- Create a bot using `BotFather`_ on Telegram to get a bot token.
7+
8+
- Add the Telegram backend to ``AUTHENTICATION_BACKENDS``::
9+
10+
AUTHENTICATION_BACKENDS = (
11+
...
12+
'social_core.backends.telegram.TelegramAuth',
13+
...
14+
)
15+
16+
- Fill the ``Bot Token`` value in the settings::
17+
18+
SOCIAL_AUTH_TELEGRAM_BOT_TOKEN = ''
19+
20+
- Add the Telegram Login Widget to your login page. The widget should be configured
21+
to send authentication data to your callback URL, which should be something like
22+
``http://example.com/complete/telegram/`` replacing ``example.com`` with your domain.
23+
24+
- The Telegram Login Widget can be added using the following HTML::
25+
26+
<script async src="https://telegram.org/js/telegram-widget.js?22"
27+
data-telegram-login="YOUR_BOT_USERNAME"
28+
data-size="large"
29+
data-auth-url="http://example.com/complete/telegram/"
30+
data-request-access="write"></script>
31+
32+
Replace ``YOUR_BOT_USERNAME`` with your bot's username (without the @ symbol)
33+
and update the ``data-auth-url`` to match your domain.
34+
35+
- The authentication process verifies the data integrity using HMAC-SHA256 with
36+
the bot token. Authentication data is considered valid for 24 hours from the
37+
``auth_date`` timestamp.
38+
39+
- The backend extracts the following user information:
40+
- User ID (required)
41+
- Username
42+
- First name
43+
- Last name
44+
- Photo URL (if available)
45+
46+
.. _BotFather: https://t.me/botfather

0 commit comments

Comments
 (0)