A secure, production-ready toolkit for generating OAuth tokens and tracking user analytics. It combines a Telegram Bot interface with a robust OAuth 2.0 Server to handle authentication flows securely.
- Magic Link Pattern: Uses secure, one-time-use links for authentication. Sensitive credentials (Client Secrets) are never exposed in URLs.
- Data Masking: Intelligent log masking protects tokens and secrets in server logs.
- Session Management: Automatic cleanup of expired sessions using MongoDB TTL indexes.
- Multi-Platform Support: Generate tokens for LinkedIn and Reddit.
- User Analytics: Tracks Daily/Weekly active users and interactions using MongoDB.
- Admin Tools: Detailed stats command (
/stats) restricted to the admin. - Public Stats: View general usage statistics with
/publicstats. - Identity Tools: Quickly fetch User ID (
/myid) or Username.
- Standalone HTTP server handling OAuth 2.0 callbacks.
- Supports both Localhost and Cloud Deployment (Railway/Heroku).
- Unified callback handler for multiple providers.
- Python 3.9+
- MongoDB Database (Local or Atlas)
- Telegram Bot Token
Copy .env.example to .env and configure the following:
# Bot Configuration
TELEGRAM_BOT_TOKEN=your_bot_token_here
ADMIN_USER_ID=123456789 # Your Telegram User ID (Integer)
# Database
MONGODB_URI=mongodb+srv://user:[email protected]/dbname
MONGODB_BOT_DB_NAME=DotSharePY
# Server Configuration
# Use http://localhost:3000 for local dev
# Use [https://your-app.up.railway.app](https://your-app.up.railway.app) for production
SERVER_BASE_URL=http://localhost:3000
- Create an app at LinkedIn Developers.
- Set Redirect URL:
YOUR_SERVER_BASE_URL/callback(e.g.,http://localhost:3000/callback). - Enable products: Sign In with LinkedIn and Share on LinkedIn.
- Create an app at Reddit Prefs.
- Select type: web app.
- Set Redirect URI:
YOUR_SERVER_BASE_URL/callback.
- Install dependencies:
pip install -r requirements.txt
- Run the bot (this will also utilize the server logic):
python bot.py
# Note: For OAuth flow, ensure server.py is running or integrated
python server.py
Build and run the container securely:
docker build -t dotshare-py .
docker run -p 3000:3000 --env-file .env dotshare-py
- Connect your GitHub repository to Railway.
- Add variables from your
.envto Railway variables. - Update
SERVER_BASE_URLto your new Railway domain (e.g.,https://dotshare.up.railway.app). - Update your LinkedIn/Reddit apps with the new Callback URL.
Run the comprehensive test suite to ensure system integrity:
python -m pytest tests/ -v
Data is stored in MongoDB collections:
users: Stores user profiles and interaction counts.analytics: Tracks daily active users (DAU).pending_auth: Temporary storage for secure Magic Links (TTL enabled).
This project is licensed under the MIT License - see the LICENSE file for details.