U
U
Ualeksej2021-08-17 12:25:39
API
Ualeksej, 2021-08-17 12:25:39

How to make authorization on the site through telegram?

Who fumbles for the telegram API? I want to make authorization on the site through TG. The user launches the bot, the bot sends him a username and password. What data should be stored in the database? Generated username and password, dialog id, something else? Tell me more?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2021-08-17
@sergiks

Better just a button: widget + register a bot. PHP authorization check
example .
If you want like in your scenario, it's more complicated and less reliable.
You can have the Bot send a JWT to the User . In which the User's Telegram-id is encrypted and, as an option, the lifetime of this token.
The user enters this token on your site (or follows a link from a bot message), and your back decrypts it (only you have the keys on the back), makes sure of its authenticity, and receives the Telegram-id of the incoming User from it.
When the token is expired or lost, the User can always get a fresh one through the bot. Nothing needs to be stored in the database for authorization.

R
robprane, 2021-08-17
@robprane

Telegram has an authorization widget: https://core.telegram.org/widgets/login .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question