tgauth is a simple authentication system using Telegram bots to generate OTP (One-Time Password) codes and exchange them for JWT (JSON Web Token) for use in your projects.
- Generates OTP codes via Telegram bot.
- Validates OTP codes and issues JWT tokens.
- Provides a secure and easy-to-use authentication system.
- Express.js
- TypeScript
- grammmy.js
- JWT (JSON Web Token)
- Node.js installed on your machine
- Telegram bot token (create a new bot and get the token from BotFather)
-
Clone the repository:
git clone https://github.com/yvexeldev/tgauth.git
-
Install dependencies:
cd tgauth npm install -
Create a
.envfile in the root directory and add variables from.env.example:DATABASE = DB_USERNAME = DB_PASSWORD = BOT_TOKEN = CHANNEL = -
Start the application:
npm run start
- Start the Telegram bot.
- Send the command
/startto the bot to receive an OTP code. - Use your phone number to get OTP code.
- Get your OTP code & send the OTP code to the entry point (e.g.,
/otp) to receive a JWT token. - Use the JWT token for authentication in your project.
Contributions are welcome! Please follow the Contributing Guidelines.