Fix Docker Spotify OAuth and add Home Assistant integration mode #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SpotifyOAuth's default behavior starts an HTTP server on port 5000 for OAuth callbacks, conflicting with the Flask app and causing
[Errno 98] Address already in usein Docker deployments.Spotify Authentication Fix
Core changes:
/callbackroute to handle OAuth redirects within Flask appopen_browser=Falsein SpotifyOAuth to prevent local server conflicts/config/.spotify_cacheFiles modified:
app/utils/spotify_manager.py- OAuth callback handling, cache pathapp/routes/web.py-/callbackroute,/api/spotify/auth-urlendpointapp/core/sync_engine.py- Auth URL generation, callback delegationapp/templates/index.html+app/static/js/app.js- Authentication UIAuthentication flow:
Users click "Authenticate with Spotify" → redirected to Spotify → callback to
/callback→ token cached and persisted.Home Assistant Integration Mode
Added dual-mode support to HA addon:
standalone(original full-app) andintegration(HTTP proxy to external Docker server).Implementation:
homeassistant/spotifytowled/config.json- Addedmodeandserver_urloptionshomeassistant/spotifytowled/run.sh- Mode detection with Flask proxy for integration modeIntegration mode configuration:
Proxy forwards all requests to external Docker server, enabling centralized management across multiple HA instances with minimal resource usage.
Backward Compatibility
All v2.0 configurations work unchanged. Standalone mode is default. No breaking changes.
Security: CodeQL analysis passed (0 vulnerabilities)
Original prompt
This section details on the original issue you should resolve
<issue_title>Docker Spotify issue</issue_title>⚠️ Default secret key is being used! This is insecure for production. Please set SECRET_KEY in your configuration.
<issue_description>2025-11-13 13:44:07,728 - app.main - WARNING -
2025-11-13 13:44:07,732 - app.main - INFO - SpotifyToWLED v2.0.0 initialized
2025-11-13 13:44:07,732 - app.main - INFO - Starting server on port 5000
2025-11-13 13:44:07,733 - werkzeug - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
2025-11-13 13:44:07,734 - werkzeug - INFO - Press CTRL+C to quit
2025-11-13 13:44:12,494 - werkzeug - INFO - 127.0.0.1 - - [13/Nov/2025 13:44:12] "GET /health HTTP/1.1" 200 -
2025-11-13 13:44:42,675 - werkzeug - INFO - 127.0.0.1 - - [13/Nov/2025 13:44:42] "GET /health HTTP/1.1" 200 -
2025-11-13 13:44:55,484 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:44:55] "GET / HTTP/1.1" 200 -
2025-11-13 13:44:55,592 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:44:55] "GET /static/js/app.js HTTP/1.1" 200 -
2025-11-13 13:44:55,593 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:44:55] "GET /static/css/style.css HTTP/1.1" 200 -
2025-11-13 13:44:56,635 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:44:56] "GET /favicon.ico HTTP/1.1" 404 -
2025-11-13 13:45:12,862 - werkzeug - INFO - 127.0.0.1 - - [13/Nov/2025 13:45:12] "GET /health HTTP/1.1" 200 -
2025-11-13 13:45:43,038 - werkzeug - INFO - 127.0.0.1 - - [13/Nov/2025 13:45:43] "GET /health HTTP/1.1" 200 -
2025-11-13 13:46:00,246 - app.core.config - INFO - Configuration saved to /config/config.json
2025-11-13 13:46:00,247 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:00] "POST /api/config/update HTTP/1.1" 302 -
2025-11-13 13:46:00,258 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:00] "GET / HTTP/1.1" 200 -
2025-11-13 13:46:00,329 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:00] "GET /static/js/app.js HTTP/1.1" 304 -
2025-11-13 13:46:00,329 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:00] "GET /static/css/style.css HTTP/1.1" 304 -
2025-11-13 13:46:13,219 - werkzeug - INFO - 127.0.0.1 - - [13/Nov/2025 13:46:13] "GET /health HTTP/1.1" 200 -
2025-11-13 13:46:19,153 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:19] "GET / HTTP/1.1" 200 -
2025-11-13 13:46:19,202 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:19] "GET /static/css/style.css HTTP/1.1" 200 -
2025-11-13 13:46:19,203 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:19] "GET /static/js/app.js HTTP/1.1" 200 -
2025-11-13 13:46:19,652 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:19] "GET /favicon.ico HTTP/1.1" 404 -
2025-11-13 13:46:29,721 - app.core.sync_engine - ERROR - Invalid configuration: At least one WLED IP address is required
2025-11-13 13:46:29,721 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:46:29] "POST /api/sync/start HTTP/1.1" 400 -
2025-11-13 13:46:43,402 - werkzeug - INFO - 127.0.0.1 - - [13/Nov/2025 13:46:43] "GET /health HTTP/1.1" 200 -
2025-11-13 13:47:03,941 - app.core.config - INFO - Configuration saved to /config/config.json
2025-11-13 13:47:03,942 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:03] "POST /api/wled/add HTTP/1.1" 302 -
2025-11-13 13:47:03,946 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:03] "GET / HTTP/1.1" 200 -
2025-11-13 13:47:03,963 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:03] "GET /static/css/style.css HTTP/1.1" 304 -
2025-11-13 13:47:03,964 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:03] "GET /static/js/app.js HTTP/1.1" 304 -
2025-11-13 13:47:08,127 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:08] "GET /api/wled/health?ip=192.168.68.102 HTTP/1.1" 200 -
2025-11-13 13:47:13,581 - werkzeug - INFO - 127.0.0.1 - - [13/Nov/2025 13:47:13] "GET /health HTTP/1.1" 200 -
2025-11-13 13:47:18,691 - app.core.config - INFO - Configuration saved to /config/config.json
2025-11-13 13:47:18,691 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:18] "POST /api/wled/add HTTP/1.1" 302 -
2025-11-13 13:47:18,694 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:18] "GET / HTTP/1.1" 200 -
2025-11-13 13:47:18,720 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:18] "GET /static/css/style.css HTTP/1.1" 304 -
2025-11-13 13:47:18,721 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:18] "GET /static/js/app.js HTTP/1.1" 304 -
2025-11-13 13:47:28,759 - app.core.config - INFO - Configuration saved to /config/config.json
2025-11-13 13:47:28,759 - werkzeug - INFO - 192.168.68.120 - - [13/Nov/2025 13:47:28] "POST /api/wled/add HTTP/1.1" 302 -
2025-11-13 13:47:28,763 - werkzeug - INFO - 192.168.68.120 - - [13/Nov...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.