3.5 KiB
3.5 KiB
OAuth Providers Setup Guide
This guide explains how to set up OAuth authentication for various social platforms.
Supported Providers
The platform supports the following OAuth providers:
- GitHub
- X (Twitter)
- Telegram
- VK (VKontakte)
- Yandex
Environment Variables
Add the following environment variables to your .env
file:
# Google OAuth
OAUTH_CLIENTS_GOOGLE_ID=your_google_client_id
OAUTH_CLIENTS_GOOGLE_KEY=your_google_client_secret
# GitHub OAuth
OAUTH_CLIENTS_GITHUB_ID=your_github_client_id
OAUTH_CLIENTS_GITHUB_KEY=your_github_client_secret
# Facebook OAuth
OAUTH_CLIENTS_FACEBOOK_ID=your_facebook_app_id
OAUTH_CLIENTS_FACEBOOK_KEY=your_facebook_app_secret
# X (Twitter) OAuth
OAUTH_CLIENTS_X_ID=your_x_client_id
OAUTH_CLIENTS_X_KEY=your_x_client_secret
# Telegram OAuth
OAUTH_CLIENTS_TELEGRAM_ID=your_telegram_bot_token
OAUTH_CLIENTS_TELEGRAM_KEY=your_telegram_bot_secret
# VK OAuth
OAUTH_CLIENTS_VK_ID=your_vk_app_id
OAUTH_CLIENTS_VK_KEY=your_vk_secure_key
# Yandex OAuth
OAUTH_CLIENTS_YANDEX_ID=your_yandex_client_id
OAUTH_CLIENTS_YANDEX_KEY=your_yandex_client_secret
Provider Setup Instructions
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API and OAuth 2.0
- Create OAuth 2.0 Client ID credentials
- Add your callback URLs:
https://yourdomain.com/oauth/google/callback
GitHub
- Go to GitHub Developer Settings
- Create a new OAuth App
- Set Authorization callback URL:
https://yourdomain.com/oauth/github/callback
- Go to Facebook Developers
- Create a new app
- Add Facebook Login product
- Configure Valid OAuth redirect URIs:
https://yourdomain.com/oauth/facebook/callback
X (Twitter)
- Go to Twitter Developer Portal
- Create a new app
- Enable OAuth 2.0 authentication
- Set Callback URLs:
https://yourdomain.com/oauth/x/callback
- Note: X doesn't provide email addresses through their API
Telegram
- Create a bot with @BotFather
- Use
/newbot
command and follow instructions - Get your bot token
- Configure domain settings with
/setdomain
command - Note: Telegram doesn't provide email addresses
VK (VKontakte)
- Go to VK for Developers
- Create a new application
- Set Authorized redirect URI:
https://yourdomain.com/oauth/vk/callback
- Note: Email access requires special permissions from VK
Yandex
- Go to Yandex OAuth
- Create a new application
- Set Callback URI:
https://yourdomain.com/oauth/yandex/callback
- Select required permissions:
login:email login:info
Email Handling
Some providers (X, Telegram) don't provide email addresses. In these cases:
- A temporary email is generated:
{provider}_{user_id}@oauth.local
- Users can update their email in profile settings later
email_verified
is set tofalse
for generated emails
Usage in Frontend
OAuth URLs:
/oauth/google
/oauth/github
/oauth/facebook
/oauth/x
/oauth/telegram
/oauth/vk
/oauth/yandex
Each provider accepts a state
parameter for CSRF protection and a redirect_uri
for post-authentication redirects.
Security Notes
- All OAuth flows use PKCE (Proof Key for Code Exchange) for additional security
- State parameters are stored in Redis with 10-minute TTL
- OAuth sessions are one-time use only
- Failed authentications are logged for monitoring