Envoy49 / go-spotify-cli

Control Spotify with CLI commands
MIT License
128 stars 5 forks source link

Unable to play on arch linux #22

Open benduckwdesign opened 9 months ago

benduckwdesign commented 9 months ago

I will forewarn that this issue isn't specifically with your application, I think I have a system misconfiguration somewhere, but if anyone else encounters a fix for this issue on Linux it would be greatly appreciated. I was having this issue mainly with flatpaks, but since this isn't a flatpak I'm a bit lost on what the direct cause is.

Screenshot from 2024-01-05 14-35-37

bwrap: Can't mkdir /usr/lib/x86_64-linux-gnu/GL: Read-only file system
error: ldconfig failed, exit status 256

Either way, even though I have a good token I'm unable to play any music.

Envoy49 commented 9 months ago

Thanks for testing this on Linux. If anybody can try installation on Linux it will be helpful and same me some time. Otherwise I will need some time to test it myself on Linux.

benduckwdesign commented 9 months ago

OK, I found out part of the issue was I had my default web browser set to something that wasn't launching correctly (its process was likely the one causing the bwrap error, probably a flatpak version.)

I switched it to my working web browser and now I'm getting INVALID_CLIENT: Invalid redirect URI on the webpage. I didn't realize it was trying to open the web browser. Maybe you could change the message to "Opening server in web browser to get an auth token". But, I'm not sure where to go from here.

mattiasbonte commented 9 months ago

OS: Linux (Tuxedo-OS) TERM: Wezterm

I'm having a similar issue, now I guess when you run the go-spotify-cli search command, you get prompted to fill in clientId and clientSecret, and after that a server starts on port 4949.

So I'm thinking to add the server which was started to the spotify app callback url field. When I do this, im getting an error though (see below). Any ideas?

INFO[0000] Opened server to get an auth token on http://localhost:4949
ERRO[0000] Error making the GET request to: /user-modify-playback-state-auth  error="Get \"http://localhost:4949/user-modify-playback-state-auth\": dial tcp [::1]:4949: connect: connection refused"

EDIT1 : I didn't pay attention to the big blue screen after signing in with my clientId and clientSecret.. it clearly says to add these 3 urls to as callback urls in the spotify app.

http://localhost:4949/user-library-read-auth-callback
http://localhost:4949/user-read-playback-state-auth-callback
http://localhost:4949/user-modify-playback-state-auth-callback

Now to be honest this still produces the same error for me.

INFO[0000] Opened server to get an auth token on http://localhost:4949
ERRO[0000] Error making the GET request to: /user-modify-playback-state-auth  error="Get \"http://localhost:4949/user-modify-playback-state-auth\": dial tcp [::1]:4949: connect: connection refused"

A question that come to mind, shouldn't these urls be httpS when using them for callback urls?


Maybe something else, but I believe the workflow of creating an app can be added to the readme.md in case people forget about reading the blue screen :). In my experience this is usually the case in other foss cli tools, read the readme first and apply the steps, then start the tool. But maybe that is just a personal habit of mine.

Thanks for your time!

Envoy49 commented 9 months ago

OK, I found out part of the issue was I had my default web browser set to something that wasn't launching correctly (its process was likely the one causing the bwrap error, probably a flatpak version.)

I switched it to my working web browser and now I'm getting INVALID_CLIENT: Invalid redirect URI on the webpage. I didn't realize it was trying to open the web browser. Maybe you could change the message to "Opening server in web browser to get an auth token". But, I'm not sure where to go from here.

Hey, thanks for trying it again. The Invalid Redirect URI means that your app in Spotify is missing the redirection urls which need to be added. The promp which URLs needs to be added is poppint up on the any first command once the app is loaded. It is asking to add those URLs in the Spotify App then provide ClientID and ClientSecret. I will update the ReadMe to reflect the Initial Prompt steps as well. Probably something I should have done earlier.

Envoy49 commented 9 months ago

OS: Linux (Tuxedo-OS) TERM: Wezterm

I'm having a similar issue, now I guess when you run the go-spotify-cli search command, you get prompted to fill in clientId and clientSecret, and after that a server starts on port 4949.

So I'm thinking to add the server which was started to the spotify app callback url field. When I do this, im getting an error though (see below). Any ideas?

INFO[0000] Opened server to get an auth token on http://localhost:4949
ERRO[0000] Error making the GET request to: /user-modify-playback-state-auth  error="Get \"http://localhost:4949/user-modify-playback-state-auth\": dial tcp [::1]:4949: connect: connection refused"

EDIT1 : I didn't pay attention to the big blue screen after signing in with my clientId and clientSecret.. it clearly says to add these 3 urls to as callback urls in the spotify app.

http://localhost:4949/user-library-read-auth-callback
http://localhost:4949/user-read-playback-state-auth-callback
http://localhost:4949/user-modify-playback-state-auth-callback

Now to be honest this still produces the same error for me.

INFO[0000] Opened server to get an auth token on http://localhost:4949
ERRO[0000] Error making the GET request to: /user-modify-playback-state-auth  error="Get \"http://localhost:4949/user-modify-playback-state-auth\": dial tcp [::1]:4949: connect: connection refused"

A question that come to mind, shouldn't these urls be httpS when using them for callback urls?

Maybe something else, but I believe the workflow of creating an app can be added to the readme.md in case people forget about reading the blue screen :). In my experience this is usually the case in other foss cli tools, read the readme first and apply the steps, then start the tool. But maybe that is just a personal habit of mine.

Thanks for your time!

Hi, thanks for checking all these.

1) yes I will probably need to update the readme to reflect the setup steps on initial setup prompt so users don't get confused. Sorry for that. 2) there is no need for HTTPS in localhost

I tested this functionality both on Windows and Mac. Yet I haven't done that on Linux, I will need time to get Linux on my VM and try to reproduce the issue you guys are experiencing.

Or if you have time you can debug a bit more

mattiasbonte commented 9 months ago

I was able to fix it, not 100% sure this was the solution though.

I added the entry 127.0.0.1 localhost to /etc/hosts file. Restarted my terminal, and then it almost worked. I got the invalid callback url error again. For some reason the 3 urls I've added in the spotify app were gone again. After adding them again, all works as expected. So maybe the entry to the hosts file was needed in order for it to resolve the endpoint properly.

Good luck

Envoy49 commented 9 months ago

@mattiasbonte I will check it once I get a chance. Thanks a lot

mattiasbonte commented 9 months ago

Btw kuddo's for keeping the design simple.. I enjoy using it so far, and I've tried a couple of other tools like this before.

Envoy49 commented 9 months ago

@mattiasbonte you can also add aliases instead of typing go-spotify-cli <command> Will make it even easier to use it