Ensure your project has the following structure:
oauth_service/
├── setup.py
├── requirements.txt
├── init_db.py
├── README.md
├── oauth_service/
│ ├── __init__.py
│ ├── core/
│ │ ├── __init__.py
│ │ ├── db.py
│ │ └── ...
│ ├── platforms/
│ │ ├── __init__.py
│ │ ├── twitter.py
│ │ └── ...
│ └── ...
└── data/ (will be created during initialization)
└── .keys/
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Unix or MacOS:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install package in development mode
pip install -e .# Copy environment template
cp .env.example .env
# Edit .env with your credentials
# Required variables:
# - TWITTER_CLIENT_ID
# - TWITTER_CLIENT_SECRET
# - LINKEDIN_CLIENT_ID
# - LINKEDIN_CLIENT_SECRET
# etc...# Run the initialization script
python init_db.py
# This will:
# - Create the data directory
# - Create the .keys directory with proper permissions
# - Initialize the SQLite database# Method 1: Using python directly
python oauth_service/main.py
# Method 2: Using uvicorn
uvicorn oauth_service.main:app --host 0.0.0.0 --port 8000 --reload
# The API will be available at:
# - API documentation: http://localhost:8000/docs
# - Alternative docs: http://localhost:8000/redoc
# - Health check: http://localhost:8000/health# In .env:
ENVIRONMENT=development
DEBUG=True
# Start with reload:
uvicorn oauth_service.main:app --host 0.0.0.0 --port 8000 --reload# In .env:
ENVIRONMENT=production
DEBUG=False
# Start with gunicorn (recommended for production):
gunicorn oauth_service.main:app -w 4 -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8000- Module Not Found Errors
# Ensure you're in the project root and run:
pip install -e .- Permission Issues
# On Unix systems, ensure proper permissions:
chmod 700 data/.keys- Database Initialization Fails
# Check directory permissions
# Ensure SQLite is available
# Verify database path in .env- OAuth Errors
# Verify credentials in .env
# Check callback URLs match your OAuth app settings
# Ensure proper scopes are configured