5.7 KiB
Distribution Guide
How the Config System Works with PyInstaller
Architecture Overview
The application uses a two-location file system:
-
Bundled Files (Read-Only) - Inside the .exe
- Python source code
- Web assets (
app/assets/web/) - Everything compiled into the executable
-
User Data Directory (Read-Write) - User's local machine
- Configuration:
%LOCALAPPDATA%\StreamerWidgets\config.json - OAuth Tokens:
%LOCALAPPDATA%\StreamerWidgets\tokens.json - Album Art:
%LOCALAPPDATA%\StreamerWidgets\art\
- Configuration:
Why This Works Well
Benefits:
- ✅ No hardcoded credentials in the .exe
- ✅ Survives updates - User config persists when you release new versions
- ✅ User-specific - Each user has their own OAuth credentials
- ✅ Secure - Credentials never in source control or distributed executable
- ✅ Easy to find - Standard Windows application data location
User Experience:
- User downloads and runs
streamer-widgets.exe - App creates
config.jsonautomatically on first run - User visits http://127.0.0.1:8765/config
- Clicks "Open Config Directory" button
- Edits
config.jsonwith their OAuth credentials - Restarts the app
- OAuth authentication works!
Building the Executable
Build Command
uv sync --group build
pyinstaller --noconsole --onefile --name streamer-widgets ^
--add-data "app/assets/web;app/assets/web" ^
run_tray.py
What Gets Bundled
- All Python code
app/assets/web/directory (HTML, CSS, JS for widgets)- Python dependencies
What Does NOT Get Bundled
config.json- Created at runtime in user directorytokens.json- Created when user authenticatesconfig.example.json- Template file (not needed in .exe)
Distribution Checklist
When distributing the application:
- Build the executable with PyInstaller
- Test the .exe on a clean machine (no Python installed)
- Verify config directory creation works
- Test "Open Config Directory" button in web UI
- Include
CHAT_SETUP.mdor link to documentation - Provide example OAuth setup instructions
User Setup Instructions (for README/docs)
For End Users
First Run:
- Run
streamer-widgets.exe - The app creates a configuration file automatically
- Open http://127.0.0.1:8765/config in your browser
Setting Up Chat Authentication:
- In the config UI, you'll see a warning if OAuth is not configured
- Click the "📁 Open Config Directory" button
- This opens:
C:\Users\YourName\AppData\Local\StreamerWidgets\ - Edit
config.jsonwith your OAuth credentials:- Get Twitch credentials from https://dev.twitch.tv/console/apps
- Get YouTube credentials from https://console.cloud.google.com/
- Save the file
- Restart the application
- Return to http://127.0.0.1:8765/config and click "Login with Twitch/YouTube"
Example config.json:
{
"twitch_oauth": {
"client_id": "your_twitch_client_id_here",
"client_secret": "your_twitch_client_secret_here",
"redirect_uri": "http://localhost:8765/auth/twitch/callback"
},
"youtube_oauth": {
"client_id": "your_youtube_client_id.apps.googleusercontent.com",
"client_secret": "your_youtube_client_secret_here",
"redirect_uri": "http://localhost:8765/auth/youtube/callback"
},
"server_host": "127.0.0.1",
"server_port": 8765
}
Troubleshooting for Users
"I can't find the config file"
- Visit http://127.0.0.1:8765/config
- The warning box shows the exact path
- Or click "Open Config Directory" to open it directly
"OAuth isn't working"
- Check that
client_idandclient_secretare filled in (not placeholders) - Make sure you restarted the app after editing config.json
- Verify the redirect URIs match in both:
- Your Twitch/YouTube developer console
- The
config.jsonfile
"Config directory won't open"
The path is always: %LOCALAPPDATA%\StreamerWidgets\
In Windows:
- Press
Win + R - Type:
%LOCALAPPDATA%\StreamerWidgets - Press Enter
Updates and Versioning
When you release a new version:
- Users download the new
.exe - Config persists - No need to reconfigure OAuth
- Tokens persist - Users stay authenticated
- Just replace the old .exe with the new one
The config directory is separate from the executable, so updates are seamless.
Security Considerations
What's Safe:
- Distribute
streamer-widgets.exepublicly - Share the source code on GitHub
- Include
config.example.jsonas a template
What to NEVER Distribute:
- Actual
config.jsonwith real credentials tokens.jsonfiles- Real OAuth Client IDs/Secrets
User Responsibility:
- Users must obtain their own OAuth credentials
- Credentials are stored locally on their machine only
- Never share
config.jsonortokens.jsonfiles
Advantages Over Alternatives
Why Not Environment Variables?
❌ Hard for non-technical users ❌ Doesn't work well with PyInstaller .exe ❌ Difficult to edit and manage
Why Not Hardcoded Credentials?
❌ Security risk ❌ Every user would use the same credentials ❌ Would hit OAuth rate limits ❌ Can't distribute publicly
Why Config File in User Directory?
✅ Standard practice for desktop apps ✅ Survives application updates ✅ User-specific credentials ✅ Easy to locate and edit ✅ Secure (local machine only) ✅ Works perfectly with PyInstaller
Summary
The config system is production-ready for distribution:
- No code changes needed by end users
- Auto-creates config on first run
- Easy to find via UI button
- Persists across updates
- Secure - no credentials in .exe
- User-friendly - clear instructions in UI
Just build the .exe and distribute it. Users will be guided through the setup process by the web UI.