Prerequisites
Before you begin, ensure you have the following installed:- Python 3.x - The application is built with Flask and requires Python 3.7 or higher
- pip - Python package installer (usually comes with Python)
- ngrok - Required for OAuth callback handling during local development
Yahoo Developer Account Setup
Create Yahoo Developer Application
Visit the Yahoo Developer Network and create a new application:
- Select Fantasy Sports API access
- Choose Read permissions (required for fetching league data)
- Note your Client ID and Client Secret - you’ll need these later
Install ngrok
Download and install ngrok from ngrok.com:
Configure Environment Variables
Create a Edit See Environment Variables for detailed explanations.
.env file in the project root directory:.env with your configuration:Start ngrok Tunnel
In a separate terminal window, start ngrok to tunnel to port 5000:You’ll see output like:Copy the HTTPS URL (e.g.,
https://abc123def456.ngrok.io) - you’ll need this for the next step.Update Yahoo App Redirect URI
Go back to your Yahoo Developer application settings and update:
- Redirect URI:
https://your-ngrok-url.ngrok.io/callback
your-ngrok-url with your actual ngrok domain.Run the Application
Start the Flask development server:The application will start in debug mode on port 5000:
Development Features
When running withFLASK_ENV=development, the application automatically:
- Loads environment variables from
.envfile usingpython-dotenv - Enables Flask debug mode for auto-reload on code changes
- Provides detailed error messages and stack traces
- Logs informational messages to help with debugging
Debug Endpoints
The application includes helpful debug endpoints for development:| Endpoint | Description |
|---|---|
/debug/league_settings | View raw league settings JSON |
/debug/scoreboard?week=1 | View raw scoreboard data for a specific week |
Troubleshooting
OAuth redirect fails
OAuth redirect fails
- Verify your ngrok URL matches exactly in Yahoo app settings
- Ensure you’re accessing via the HTTPS ngrok URL, not localhost
- Check that ngrok is still running in the background
Module import errors
Module import errors
- Ensure all dependencies are installed:
pip install -r requirements.txt - Check you’re using Python 3.7 or higher:
python --version - Activate your virtual environment if using one
Environment variables not loading
Environment variables not loading
- Verify
.envfile is in the project root directory - Check file formatting (no quotes around values unless needed)
- Ensure
FLASK_ENV=developmentis set to trigger dotenv loading
Yahoo API authentication errors
Yahoo API authentication errors
- Verify your Client ID and Secret are correct
- Check that the Yahoo app has Fantasy Sports API permissions
- Ensure the redirect URI in Yahoo settings exactly matches your ngrok URL +
/callback
Next Steps
Environment Variables
Learn about all configuration options
Heroku Deployment
Deploy your app to production