Login to web app using Telegram
Feb 2018 update: Telegram now officially has Telegram Login ! I took a brief look on how the new login feature work and I think the main difference is that the auth data is signed using the bot’s token while in my approach, it was signed using the website’s secret key.
I have long thinking about this. The idea is that, to login to the django site, you send a message to a bot which running as webhook in the django app. Upon receiving the message, the bot will create new user using Telegram username. The bot will then return a special url that user should open in order to login. So I decided to build a POC for this.
This should not be specific to Django only. You can use any framework like Laravel or plain PHP to implement this. So let’s look at the flow.
When you open the page that need to login, it will provide you with link to a Telegram bot.
After tapping on the login link, it will open our Telegram app:-
After tapping the “Start” button, we will get another button containing the login link.
Clicking the login link, Telegram will prompt to verify we want to open the external url.
Tap on open and it will open the login page, with a confirmation we want to login as the username.
After submitting the button, we’re logged in !
You can check the code at https://github.com/k4ml/gramlogin.