This project demonstrates how to implement authentication in Telegram bot using OpenId Connect (OIDC).
Implementation tools:
- Keycloak — open source Identity and Access Management solution (OpenId provider).
- Spring Boot — application framework.
- TelegramBots — library to create Telegram Bots in Java.
- ScribeJava — OAuth client Java library.
- Java JWT от Auth0 — Java implementation of JSON Web Token (JWT).
This demo comprises of two services:
- Telegram bot
- OpenId provider
Ensure you have JDK 11. To build the project run:
./mvnw package
Ensure you have Docker and Docker Compose installed.
Create file .env
in project root directory using .env.template
as a base. Specify correct values for the
following entries:
BASEURL
:http://address:8080
whereaddress
is an IP address/domain name of your host.OIDC_KEYCLOAK_BASEURL
:http://address:8180
whereaddress
is an IP address/domain name of your host (do not uselocalhost
).BOT_USERNAME
: name of your telegram bot.BOT_TOKEN
: token of your telegram bot.
Ok. Now, run the demo using following command:
docker-compose up --build