librespot-org / librespot

Open Source Spotify client library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to get client token

acolombier opened this issue · comments

Describe the bug

When using the playlist_tracks.rs example with a large playlist (+300 songs), there is eventually a failure due to a "too many request" exception.

The exception is raised by SpClient::client_token, which seems to constantly fail with a 400 Bad Request, thus gets called at each API request.

To reproduce

Steps to reproduce the behavior:

  1. Build and launch the playlist_tracks.rs example with a large playlist (+300 songs)
  2. See error

Log

...
2024-03-10T00:07:05Z DEBUG librespot_core::spclient] Client token unavailable or expired, requesting new token.
[2024-03-10T00:07:05Z DEBUG librespot_core::http_client] Requesting https://clienttoken.spotify.com/v1/clienttoken
[2024-03-10T00:07:05Z DEBUG hyper::client::pool] reuse idle connection for ("https", clienttoken.spotify.com)
[2024-03-10T00:07:05Z DEBUG h2::codec::framed_write] send frame=Headers { stream_id: StreamId(419), flags: (0x4: END_HEADERS) }
[2024-03-10T00:07:05Z DEBUG h2::codec::framed_write] send frame=Data { stream_id: StreamId(419), flags: (0x1: END_STREAM) }
[2024-03-10T00:07:05Z DEBUG h2::codec::framed_read] received frame=Headers { stream_id: StreamId(419), flags: (0x5: END_HEADERS | END_STREAM) }
[2024-03-10T00:07:05Z DEBUG h2::codec::framed_read] received frame=Ping { ack: false, payload: [0, 0, 0, 0, 0, 0, 4, 101] }
[2024-03-10T00:07:05Z DEBUG h2::codec::framed_write] send frame=Ping { ack: true, payload: [0, 0, 0, 0, 0, 0, 4, 101] }
[2024-03-10T00:07:05Z WARN  librespot_core::spclient] Unable to get client token: Client specified an invalid argument { Response status code: 400 Bad Request } Trying to continue without...
[2024-03-10T00:07:05Z DEBUG librespot_core::http_client] Requesting https://gew1-spclient.spotify.com:443/metadata/4/track/...?product=0&country=GB&salt=436026428
...

Host (what you are running librespot on):

  • OS: Linux
  • Platform: amd64
  • Version: dev

Turns out that this could be fixed by update the Spotify version, Happy to issue a PR if you want?

Yes please, fixing is good