Repository: aome510/spotify-player (language: rust)

Issue:
`spotify_player authenticate` error message
Not so much a bug and more of a support request. 
Trying to run for the first time with `spotify_player authenticate`, I get the error message :
```
Error: try to connect to a client

Caused by:
    No cached credentials found, please authenticate the application first.
```

I have no idea which folder this is scanning from, nor what cached credentials it is looking for. I've created an app with Spotify, and used the generated client ID in .config/spotify-player/app.toml. I may have missed something in the documentation, but I think this is all I need? 

**Environment**
- OS: macOS Monterey 12.6
- Application version: cargo 1.74.0
- Application features: default features, I didn't enable anything 




Discussion / hints:
HI @liiyung, this is a bug when handling CLI commands. I'll put up a fix soon. In the meantime, you can authenticate the app and create cached credentials by just running `spotify_player`.

Fix patch:
diff --git a/spotify_player/src/cli/handlers.rs b/spotify_player/src/cli/handlers.rs
index b1c8be44..81c800ec 100644
--- a/spotify_player/src/cli/handlers.rs
+++ b/spotify_player/src/cli/handlers.rs
@@ -180,6 +180,14 @@ fn try_connect_to_client(socket: &UdpSocket, configs: &state::Configs) -> Result
 pub fn handle_cli_subcommand(cmd: &str, args: &ArgMatches, configs: &state::Configs) -> Result<()> {
     let socket = UdpSocket::bind("127.0.0.1:0")?;
 
+    // handle `authenticate` command separately as `authenticate` doesn't require a client
+    if cmd == "authenticate" {
+        let auth_config = AuthConfig::new(configs)?;
+        let rt = tokio::runtime::Runtime::new()?;
+        rt.block_on(new_session_with_new_creds(&auth_config))?;
+        std::process::exit(0);
+    }
+
     try_connect_to_client(&socket, configs).context("try to connect to a client")?;
 
     // construct a socket request based on the CLI command and its arguments
@@ -191,12 +199,6 @@ pub fn handle_cli_subcommand(cmd: &str, args: &ArgMatches, configs: &state::Conf
         "like" => Request::Like {
             unlike: args.get_flag("unlike"),
         },
-        "authenticate" => {
-            let auth_config = AuthConfig::new(configs)?;
-            let rt = tokio::runtime::Runtime::new()?;
-            rt.block_on(new_session_with_new_creds(&auth_config))?;
-            std::process::exit(0);
-        }
         _ => unreachable!(),
     };
 


Test patch: