Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement OAuth and refactor config #1321

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

eladyn
Copy link
Member

@eladyn eladyn commented Dec 30, 2024

This builds on top of #1317 and implements the missing OAuth support, which replaces the no longer available username + password method. Since this required some refactoring of the configuration anyway, I replaced structopt with the (actively developed) clap, which is the successor of structopt.

By removing the username + password method, we basically get rid of all the sensitive value handling, e.g. the keyring. (Well, one could still store the cached credentials in the keyring, but that hasn't happened before either, so this could be a future extension.)

The OAuth support is a bit clunky at the moment and surely could use some refinement in the future, but since this has been missing for quite some time now, it's probably better to put it out there and iterate on that later.

If I'm not mistaken, all configuration changes should be backwards compatible so far (or at least not error on previously working configs, of course username or password values are no longer used).

The current design of the authentication is as follows:

  • By using the spotifyd auth(enticate) subcommand, one initiates the OAuth process and is directed to accounts.spotify.com. After logging in there, we receive the token and exchange it for a longer-lived credential blob. This blob is stored at $cache_directory/oauth/credentials.json
  • If spotifyd finds an authentication blob from oauth on startup, it uses that for the first session.
  • If not disabled via --disable-discovery or disable_discovery = true (even if an oauth blob is present), discovery is started and selecting a device there ends the current session and starts a new one.
  • The last active session is also cached in $cache_directory/credentials.json and will be used on startup, when no oauth blob can be found.

Closes #800, closes #778 (due to configuration refactor).
Fixes #1293 (oauth support).
Fixes #1212 (new credential caching logic, no usernames necessary anymore).

Any testing is highly appreciated! Also, none of the changes have been documented so far so that still has to be done before a release.

@bjornfor
Copy link

If I'm not mistaken, all configuration changes should be backwards compatible so far (or at least not error on previously working configs, of course username or password values are no longer used).

I understand this as the username, password and password_cmd in the configuration file will now be ignored, and login requires some manual steps in a web browser. Correct?

@eladyn
Copy link
Member Author

eladyn commented Dec 30, 2024

I understand this as the username, password and password_cmd in the configuration file will now be ignored, and login requires some manual steps in a web browser. Correct?

Yes, that's correct. Alternatively we could maybe keep them around for now and warn the user, when they are encountered...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Bad credentials" error when starting spotifyd Credential cache is ignored by default
2 participants