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

[Feature Request]Authentication is impossible with librespot >=0.5 due to --password being deprecated #96

Closed
swede89 opened this issue Nov 21, 2024 · 9 comments · Fixed by #97
Labels
feature-request Request for a new feature

Comments

@swede89
Copy link

swede89 commented Nov 21, 2024

Hi. I am happy that you offer this docker image! Thanks a lot!

Is your feature request related to a problem? Please describe.
yes, as of librespot 0.5 --password is deprecated. Therefore, login with librespot-docker is impossible.

Describe the solution you'd like
Support for any of the oauth processes or the access-token, rf. https://github.com/librespot-org/librespot/wiki/Options#Authentication

@swede89 swede89 added the feature-request Request for a new feature label Nov 21, 2024
@GioF71
Copy link
Owner

GioF71 commented Nov 21, 2024

I will try to support this. I can't promise an ETA though, but I'd like it to be done ASAP. Cheers

@GioF71
Copy link
Owner

GioF71 commented Nov 22, 2024

Hello, I could authenticate using the following procedure:

Create a tmp directory named "tmp" under your working directory, when run:

docker run -it --rm --user $(id -u):$(id -g) -v $(pwd)/tmp:/tmp-cache --entrypoint "/usr/bin/librespot" giof71/librespot --cache /tmp-cache --enable-oauth --oauth-port 0

Open the url, paste back the redirect url, what a while (a few millisec actually) that Librespot starts, then simply exit the process using CTRL-C.
You should now have a valid credentials.json in your tmp directory.
Mount that file either as /data/cache/credentials.json or /data/system-cache/credentials.json, or simply save in the mounted directory for cache or system cache. Restart the container and it should be authenticated.

Let me know if this works. If it does, next step is updating the documentation.

@GioF71
Copy link
Owner

GioF71 commented Nov 22, 2024

Alternatively to mounting, you can copy the credentials file to the running container using something like this:

docker cp tmp/credentials.json librespot:/data/system-cache/credentials.json

assuming your container is named librespot and you want to copy the file to the system cache. Make sure the system-cache is enabled and persistent. You will need to restart the container.

@swede89
Copy link
Author

swede89 commented Nov 22, 2024

Thanks. That works. It is hacky though.
I would prefer a solution on top of the existing mechanisms in your project.
How about adding an env to activate the oauth process. Then, the user can

  1. view the container logs
  2. copy the link to the spotify login from the logs
  3. paste it to any web browser
  4. finalize the login

While the container uses the cache mechanisms, the login should persist. Correct me if I am wrong :-)

@GioF71
Copy link
Owner

GioF71 commented Nov 22, 2024

Hello, I know it's hacky and we need something better. About your proposed solution, two things I don't particularly like:

  1. We would need to changing the env after the first start (so edit .env twice)
  2. unless you run with "docker-compose run", AFAIK the terminal would never be interactive, and we need to paste an url to that terminal.

Am I wrong or missing something?

About your last questions, yes the login persists if you have a volume mounted as system-cache and system-cache is enabled.

@GioF71
Copy link
Owner

GioF71 commented Nov 22, 2024

Oh well, thinking again... we would not need to edit the env twice. If the --enable-oauth is part of the command, the second time it works just fine without user interaction.
We would just need to execute the first run using "docker-compose run".
After that one might simply run the usual docker-compose. Let me do some testing!

@GioF71
Copy link
Owner

GioF71 commented Nov 22, 2024

Hello, I could make it work pretty seamlessly... thank you for your suggestion. I expect to be able to build a new release later today or by the end of the weekend

GioF71 added a commit that referenced this issue Nov 22, 2024
@GioF71 GioF71 linked a pull request Nov 22, 2024 that will close this issue
GioF71 added a commit that referenced this issue Nov 22, 2024
@GioF71
Copy link
Owner

GioF71 commented Nov 22, 2024

It should work hopefully... just add

- ENABLE_OAUTH=headless

to your compose file.
For the first run, use:

docker-compose run librespot

then authenticate and authorize the device.
Then you should be able to run normally without changing the compose or the .env file.

@swede89
Copy link
Author

swede89 commented Nov 26, 2024

Congrats, Gio!
I am looking forward to try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants