Telegram OAuth server for Telegram Login for Websites
This small tool allows you to deploy use Telegrams non-oauth compliant login API with OAuth 2.0 and OIDC compliant tools like authentik
These will likely remain, as this is mostly a project for my own use, feel free to copy the code and make your own if you need more features
- Only a single OAuth client is supported
- Only the
grant_type: authorization_code
andresponse_type: code
are supported - Only the OIDC authorize, token and profile endpoints are supported
The application is distributed under the ghcr.io/drschlaubi/telegram-oauth docker image and can be setup the following way
- Set up a Telegram bot
- Message @BotFather on Telegram
- Type
/newbot
and enter a bot Display name and username - use the
/setdomain
command to set the Domain used for this application
- Setup the application
- Install Docker
- Download the docker-compose file
- Create a
.env
file like this and rundocker compose up -d
BOT_USERNAME=<telegram bot username>
TELEGRAM_TOKEN=<telegram token>
URL=<url from step 1.3>
JWT_SECRET=<can be generated using pwgen>
OAUTH_CLIENT_ID=authentik
OAUTH_CLIENT_SECRET=<can be generated using pwgen>
OAUTH_REDIRECT_URIS=<redirect uri>
These are directly compatible with Authentik, just put the URLs in.
Authorize: <URL>/oauth/authorize
Token: <URL>/oauth/token
Profile: <URL>/oauth/profile
{
"sub": "telegram user id",
"name": "telegram user name",
"given_name": "telegram first name",
"family_name": "telegram last name",
"picture": "<url to t.me>"
}