A Cloudflare Worker providing OAuth2 authentication for Telegram users
GET /oauth/authorize
Initiates the OAuth2 flow by redirecting users to Telegram for authentication.
client_id - Your OAuth client IDredirect_uri - Where to redirect after authorizationstate - Optional state parameter for CSRF protectionscope - Optional scope (defaults to "read")
GET /oauth/authorize?client_id=your_client_id&redirect_uri=https://your-app.com/callback&state=random_state
POST /oauth/token
Exchanges authorization code for access token.
grant_type - Must be "authorization_code"code - Authorization code from callbackclient_id - Your OAuth client IDclient_secret - Your OAuth client secretredirect_uri - Must match the one used in authorization
GET /oauth/userinfo
Returns user information for the authenticated user.
Authorization: Bearer YOUR_ACCESS_TOKEN
TELEGRAM_BOT_TOKEN - Your bot's API token (bot ID will be extracted from this)TELEGRAM_BOT_USERNAME - Your bot's username (without @)OAUTH_CLIENT_ID - Your OAuth client IDOAUTH_CLIENT_SECRET - Your OAuth client secretREDIRECT_URI - Your callback URLVALIDATE_REDIRECT_URI - Set to "false" to disable redirect URI validationstate parameter to prevent CSRF attacks