[GH-ISSUE #537] FR: Store client_id outside dotfiles #307

Closed
opened 2026-03-02 23:46:24 +03:00 by kerem · 13 comments
Owner

Originally created by @chrisgrieser on GitHub (Aug 8, 2024).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/537

Is your feature request related to a problem? Please describe.
I do version control and publish my .config directory in a GitHub repo, as quite a lot of people do. Thus, Due to the inclusion of the client_id, this results in having to gitignore the ~/.config/spotify_player/app.toml, as otherwise the id would be leaked.

Describe the solution you'd like
Save client_id outside the app.toml, so the remainder of the spotify-player-config can be stored in a public git repo without any trouble.

The client_id could then be read from an environment variable, which one could save in .zshenv.

Alternatively, support something like the password_cmd from spotifyd: https://docs.spotifyd.rs/config/File.html

# This is an alternative to the `password` field. Both
# can't be used simultaneously.
password_cmd = "command_that_writes_password_to_stdout"

Describe alternatives you've considered

  • gitignoring the app.toml and manually updating it all the time.
  • symlinking the app.toml into a private cloud storage.
Originally created by @chrisgrieser on GitHub (Aug 8, 2024). Original GitHub issue: https://github.com/aome510/spotify-player/issues/537 **Is your feature request related to a problem? Please describe.** I do version control and publish my `.config` directory in a GitHub repo, as quite a lot of people do. Thus, Due to the inclusion of the `client_id`, this results in having to gitignore the `~/.config/spotify_player/app.toml`, as otherwise the id would be leaked. **Describe the solution you'd like** Save `client_id` outside the `app.toml`, so the remainder of the spotify-player-config can be stored in a public git repo without any trouble. The client_id could then be read from an environment variable, which one could save in `.zshenv`. Alternatively, support something like the `password_cmd` from `spotifyd`: https://docs.spotifyd.rs/config/File.html ```toml # This is an alternative to the `password` field. Both # can't be used simultaneously. password_cmd = "command_that_writes_password_to_stdout" ``` **Describe alternatives you've considered** - gitignoring the `app.toml` and manually updating it all the time. - symlinking the `app.toml` into a private cloud storage.
kerem 2026-03-02 23:46:24 +03:00
Author
Owner

@masroof-maindak commented on GitHub (Aug 10, 2024):

@aome510 Hi, could you please assign this to me? I've never programmed in Rust before so I'd like to start simple and give this a shot.

<!-- gh-comment-id:2280744547 --> @masroof-maindak commented on GitHub (Aug 10, 2024): @aome510 Hi, could you please assign this to me? I've never programmed in Rust before so I'd like to start simple and give this a shot.
Author
Owner

@juliamertz commented on GitHub (Aug 10, 2024):

@masroof-maindak I have already started work on this, though i can't test it out right now since authentication with spotify is broken. You can check it out here

Edit:
Authentication is working again for me, tested it on Linux and everything works fine. Only need someone on windows to confirm this is working for them as well.

<!-- gh-comment-id:2281907466 --> @juliamertz commented on GitHub (Aug 10, 2024): @masroof-maindak I have already started work on this, though i can't test it out right now since authentication with spotify is broken. You can check it out [here](https://github.com/juliamertz/spotify-player/tree/private-client-id) Edit: Authentication is working again for me, tested it on Linux and everything works fine. Only need someone on windows to confirm this is working for them as well.
Author
Owner

@masroof-maindak commented on GitHub (Aug 10, 2024):

@masroof-maindak I have already started work on this

Oh well, bummer. Thank you for your contribution regardless.

<!-- gh-comment-id:2282181966 --> @masroof-maindak commented on GitHub (Aug 10, 2024): > @masroof-maindak I have already started work on this Oh well, bummer. Thank you for your contribution regardless.
Author
Owner

@chrisgrieser commented on GitHub (Jan 3, 2025):

@juliamertz Sorry, I am just testing this now, since the authentication was previously broken.

I tried client_id_command = 'cat "/path/to/file"' (with the file containing nothing but the client_id) and it is unfortunately not working for me.

cat "/path/to/file" does output the correct client_id, and setting client_id = "..." also does work fine. I also tried client_id_command = 'cat "/path/to/file"' | tr -d "\n" just in case, but that also does not work.

I am on macOS 14.5 (i386), with spotify_player 0.20.4.

<!-- gh-comment-id:2569931374 --> @chrisgrieser commented on GitHub (Jan 3, 2025): @juliamertz Sorry, I am just testing this now, since the authentication was previously broken. I tried `client_id_command = 'cat "/path/to/file"'` (with the file containing nothing but the client_id) and it is unfortunately not working for me. `cat "/path/to/file"` does output the correct client_id, and setting `client_id = "..."` also does work fine. I also tried `client_id_command = 'cat "/path/to/file"' | tr -d "\n"` just in case, but that also does not work. I am on macOS 14.5 (i386), with spotify_player 0.20.4.
Author
Owner

@juliamertz commented on GitHub (Jan 4, 2025):

@chrisgrieser Looks like your config isn't quite right, can you try putting this in your app.toml?

client_id_command = { command = "cat", args = ["/run/secrets/spotify_client_id"] }
<!-- gh-comment-id:2571364657 --> @juliamertz commented on GitHub (Jan 4, 2025): @chrisgrieser Looks like your config isn't quite right, can you try putting this in your app.toml? ```toml client_id_command = { command = "cat", args = ["/run/secrets/spotify_client_id"] } ```
Author
Owner

@chrisgrieser commented on GitHub (Jan 4, 2025):

@juliamertz that is also not working for me.

btw, the docs on config options do not mention that client_id_command needs sub-keys, so there is no way to know that from a user perspective.

<!-- gh-comment-id:2571368836 --> @chrisgrieser commented on GitHub (Jan 4, 2025): @juliamertz that is also not working for me. btw, the [docs on config options](https://github.com/aome510/spotify-player/blob/master/docs/config.md#general) do not mention that `client_id_command` needs sub-keys, so there is no way to know that from a user perspective.
Author
Owner

@juliamertz commented on GitHub (Jan 4, 2025):

@chrisgrieser That's weird, i'm using the exact same option and it's working fine for me.
Can you check the logs in ~/.cache/spotify-player/*.log and verify your configuration is being parsed correctly?

Also there's a bit on using commands here, though i agree this is a bit unclear

<!-- gh-comment-id:2571378773 --> @juliamertz commented on GitHub (Jan 4, 2025): @chrisgrieser That's weird, i'm using the exact same option and it's working fine for me. Can you check the logs in `~/.cache/spotify-player/*.log` and verify your configuration is being parsed correctly? Also there's a bit on using commands [here](https://github.com/aome510/spotify-player/blob/master/docs/config.md#player-event-hook-command), though i agree this is a bit unclear
Author
Owner

@masroof-maindak commented on GitHub (Jan 4, 2025):

@juliamertz same issue.

When I include the following line in config:

client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] }

My app refuses to launch, and this is what I get: https://pastebin.com/Epz0mfxa

Comment it out and it works just fine.

client_id_command = "cat ~/.cache/spotify_client_id"

Doesn't prevent my spotify_player from launching, but it also doesn't work either.

<!-- gh-comment-id:2571383930 --> @masroof-maindak commented on GitHub (Jan 4, 2025): @juliamertz same issue. When I include the following line in config: ```toml client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] } ``` My app refuses to launch, and this is what I get: https://pastebin.com/Epz0mfxa Comment it out and it works just fine. ```toml client_id_command = "cat ~/.cache/spotify_client_id" ``` Doesn't prevent my spotify_player from launching, but it also doesn't work either.
Author
Owner

@juliamertz commented on GitHub (Jan 4, 2025):

client_id_command = "cat ~/.cache/spotify_client_id"

Doesn't prevent my spotify_player from launching, but it also doesn't work either.

This won't actually parse so it'd be treated as a None value and default to client_id

When I include the following line in config:

client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] }

I just tried it out with your setup and it looks like you need to specify the full path to the file.
Using ~ in place of /home/user also results in a panic for me

<!-- gh-comment-id:2571393804 --> @juliamertz commented on GitHub (Jan 4, 2025): > ```toml > client_id_command = "cat ~/.cache/spotify_client_id" > ``` > > Doesn't prevent my spotify_player from launching, but it also doesn't work either. This won't actually parse so it'd be treated as a None value and default to `client_id` > When I include the following line in config: > > ```toml > client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] } > ``` I just tried it out with your setup and it looks like you need to specify the full path to the file. Using `~` in place of `/home/user` also results in a panic for me
Author
Owner

@masroof-maindak commented on GitHub (Jan 4, 2025):

client_id_command = "cat ~/.cache/spotify_client_id"

Doesn't prevent my spotify_player from launching, but it also doesn't work either.

This won't actually parse so it'd be treated as a None value and default to client_id

When I include the following line in config:

client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] }

I just tried it out with your setup and it looks like you need to specify the full path to the file. Using ~ in place of /home/user also results in a panic for me

Okay, so it boots fine now, and allows me to detect music from my phone, but no longer lists my machine as a 'device' so I can't play music on my own or switch from my phone to my machine.

This goes away once I comment out the client_id_command line.

2025-01-05_012959
image

D in either case does not list my machine as a device.

<!-- gh-comment-id:2571404937 --> @masroof-maindak commented on GitHub (Jan 4, 2025): > > ```toml > > client_id_command = "cat ~/.cache/spotify_client_id" > > ``` > > > > > > > > > > > > > > > > > > > > > > > > Doesn't prevent my spotify_player from launching, but it also doesn't work either. > > This won't actually parse so it'd be treated as a None value and default to `client_id` > > > When I include the following line in config: > > ```toml > > client_id_command = { command = "cat", args = ["~/.cache/spotify_client_id"] } > > ``` > > I just tried it out with your setup and it looks like you need to specify the full path to the file. Using `~` in place of `/home/user` also results in a panic for me Okay, so it boots fine now, and allows me to detect music from my phone, but no longer lists my machine as a 'device' so I can't play music on my own or switch from my phone to my machine. This goes away once I comment out the `client_id_command line`. ![2025-01-05_012959](https://github.com/user-attachments/assets/07cf51c8-8587-4728-b434-1b5b537df25c) ![image](https://github.com/user-attachments/assets/4e966873-c1f9-4f9b-adb9-221e620cd0b1) **D** in either case does *not* list my machine as a device.
Author
Owner

@chrisgrieser commented on GitHub (Jan 5, 2025):

@juliamertz I just experimented at bit, and it appears the issue is the trailing newline:

# does not work
client_id_command = { command = "echo", args = ["my-id"] }
# works
client_id_command = { command = "echo", args = ["-n", "my-id"] }

Since shell commands commonly add a newline to their output, this should be dealt with by spotify_player, imho.

<!-- gh-comment-id:2571601930 --> @chrisgrieser commented on GitHub (Jan 5, 2025): @juliamertz I just experimented at bit, and it appears the issue is the trailing newline: ```toml # does not work client_id_command = { command = "echo", args = ["my-id"] } ``` ```toml # works client_id_command = { command = "echo", args = ["-n", "my-id"] } ``` Since shell commands commonly add a newline to their output, this should be dealt with by `spotify_player`, imho.
Author
Owner

@reorx commented on GitHub (Jul 10, 2025):

Is it possible to get client id from existing environment variables? I tried the following but it does not work:

client_id_command = { command = "echo", args = ["$SPOTIFY_CLIENT_ID"] }
<!-- gh-comment-id:3057604901 --> @reorx commented on GitHub (Jul 10, 2025): Is it possible to get client id from existing environment variables? I tried the following but it does not work: ``` client_id_command = { command = "echo", args = ["$SPOTIFY_CLIENT_ID"] } ```
Author
Owner

@wawwior commented on GitHub (Oct 8, 2025):

D in either case does not list my machine as a device.

This is still the case.

<!-- gh-comment-id:3383165221 --> @wawwior commented on GitHub (Oct 8, 2025): > **D** in either case does _not_ list my machine as a device. This is still the case.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#307
No description provided.