Add access_token option - #370
Conversation
This allows logging into specific spotify account. The token is short-lived and providing expired token makes the app fail to start. But once credentials.json is cached, librespot remains logged in even the token is not set on the command line anymore. Fixes hassio-addons#369
WalkthroughThe Spotify Connect add-on gains an Changesaccess_token authentication support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@spotify/rootfs/etc/services.d/librespot/run`:
- Around line 41-43: The conditional block checking
`/data/system-cache/credentials.json` and using `bashio::config.is_empty
'access_token'` is too broad because `access_token` defaults to empty, causing
cached credentials to be deleted on every restart. Modify the condition to only
delete the credentials cache when the user has explicitly provided a new
access_token value (i.e., when access_token is NOT empty), rather than when it
is empty. This will preserve cached login credentials across restarts while
still allowing the cache to be cleared when a user intentionally provides a new
token.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c2693cf5-308b-4912-b525-dafe43eeb10f
📒 Files selected for processing (3)
spotify/DOCS.mdspotify/config.yamlspotify/rootfs/etc/services.d/librespot/run
Proposed Changes
This allows logging into specific spotify account. Since the token needs to be set on the cmdline only once (to generate credentials.json), switching to another account is a bit awkward - it requires removing old credentials.json (by setting token to empty) and only then setting new one.
With this, I can successfully use Spotify Premium account again.
Related Issues
Fixes #369
Summary by CodeRabbit
New Features
Documentation