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

400 Client Error and SpotifyOauthError #2261

Open
jsnaxl opened this issue Dec 15, 2024 · 1 comment
Open

400 Client Error and SpotifyOauthError #2261

jsnaxl opened this issue Dec 15, 2024 · 1 comment
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed

Comments

@jsnaxl
Copy link

jsnaxl commented Dec 15, 2024

System OS

Windows

Python Version

3.9 (CPython)

Install Source

pip / PyPi

Install version / commit hash

v4.2.10

Expected Behavior vs Actual Behavior

No response

Steps to reproduce - Ensure to include actual links!

  1. Download spotify playlist using "spotdl [playlist url]"
  2. Works for around 600 songs
  3. 400 error and SpotifyOauthError
  4. now it only shows error without downloading anything

Traceback

An error occurred
┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotipy\oauth2.py:256 in                    │
│ _request_access_token                                                                                               │
│                                                                                                                     │
│    253 │   │   │   │   proxies=self.proxies,                                                                        │
│    254 │   │   │   │   timeout=self.requests_timeout,                                                               │
│    255 │   │   │   )                                                                                                │
│ >  256 │   │   │   response.raise_for_status()                                                                      │
│    257 │   │   │   token_info = response.json()                                                                     │
│    258 │   │   │   return token_info                                                                                │
│    259 │   │   except requests.exceptions.HTTPError as http_error:                                                  │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py:1024 in raise_for_status │
│                                                                                                                     │
│   1021 │   │   │   )                                                                                                │
│   1022 │   │                                                                                                        │
│   1023 │   │   if http_error_msg:                                                                                   │
│ > 1024 │   │   │   raise HTTPError(http_error_msg, response=self)                                                   │
│   1025 │                                                                                                            │
│   1026 │   def close(self):                                                                                         │
│   1027 │   │   """Releases the connection back to the pool. Once this method has been                               │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
HTTPError: 400 Client Error: Bad Request for url: https://accounts.spotify.com/api/token

During handling of the above exception, another exception occurred:

┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotdl\console\entry_point.py:160 in        │
│ entry_point                                                                                                         │
│                                                                                                                     │
│   157 │   try:                                                                                                      │
│   158 │   │   # Pick the operation to perform                                                                       │
│   159 │   │   # based on the name and run it!                                                                       │
│ > 160 │   │   OPERATIONS[arguments.operation](                                                                      │
│   161 │   │   │   query=arguments.query,                                                                            │
│   162 │   │   │   downloader=downloader,                                                                            │
│   163 │   │   )                                                                                                     │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotdl\console\download.py:25 in download   │
│                                                                                                                     │
│   22 │   """                                                                                                        │
│   23 │                                                                                                              │
│   24 │   # Parse the query                                                                                          │
│ > 25 │   songs = get_simple_songs(                                                                                  │
│   26 │   │   query,                                                                                                 │
│   27 │   │   use_ytm_data=downloader.settings["ytm_data"],                                                          │
│   28 │   │   playlist_numbering=downloader.settings["playlist_numbering"],                                          │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotdl\utils\search.py:264 in               │
│ get_simple_songs                                                                                                    │
│                                                                                                                     │
│   261 │   │   │   )                                                                                                 │
│   262 │   │   │   songs.extend(full_lists)                                                                          │
│   263 │   │   elif "open.spotify.com" in request and "playlist" in request:                                         │
│ > 264 │   │   │   lists.append(Playlist.from_url(request, fetch_songs=False))                                       │
│   265 │   │   elif "open.spotify.com" in request and "album" in request:                                            │
│   266 │   │   │   lists.append(Album.from_url(request, fetch_songs=False))                                          │
│   267 │   │   elif "open.spotify.com" in request and "artist" in request:                                           │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotdl\types\song.py:306 in from_url        │
│                                                                                                                     │
│   303 │   │   - The SongList object.                                                                                │
│   304 │   │   """                                                                                                   │
│   305 │   │                                                                                                         │
│ > 306 │   │   metadata, songs = cls.get_metadata(url)                                                               │
│   307 │   │   urls = [song.url for song in songs]                                                                   │
│   308 │   │                                                                                                         │
│   309 │   │   if fetch_songs:                                                                                       │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotdl\types\playlist.py:48 in get_metadata │
│                                                                                                                     │
│    45 │   │                                                                                                         │
│    46 │   │   spotify_client = SpotifyClient()                                                                      │
│    47 │   │                                                                                                         │
│ >  48 │   │   playlist = spotify_client.playlist(url)                                                               │
│    49 │   │   if playlist is None:                                                                                  │
│    50 │   │   │   raise PlaylistError("Invalid playlist URL.")                                                      │
│    51                                                                                                               │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotipy\client.py:666 in playlist           │
│                                                                                                                     │
│    663 │   │   │   │   │   │   │   │   │    valid types are: track and episode                                      │
│    664 │   │   """                                                                                                  │
│    665 │   │   plid = self._get_id("playlist", playlist_id)                                                         │
│ >  666 │   │   return self._get(                                                                                    │
│    667 │   │   │   f"playlists/{plid}",                                                                             │
│    668 │   │   │   fields=fields,                                                                                   │
│    669 │   │   │   market=market,                                                                                   │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotdl\utils\spotify.py:195 in _get         │
│                                                                                                                     │
│   192 │   │   retries = self.max_retries  # type: ignore # pylint: disable=E1101                                    │
│   193 │   │   while response is None:                                                                               │
│   194 │   │   │   try:                                                                                              │
│ > 195 │   │   │   │   response = self._internal_call("GET", url, payload, kwargs)                                   │
│   196 │   │   │   except (requests.exceptions.Timeout, requests.ConnectionError) as exc:                            │
│   197 │   │   │   │   retries -= 1                                                                                  │
│   198 │   │   │   │   if retries <= 0:                                                                              │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotipy\client.py:251 in _internal_call     │
│                                                                                                                     │
│    248 │   │   args = dict(params=params)                                                                           │
│    249 │   │   if not url.startswith("http"):                                                                       │
│    250 │   │   │   url = self.prefix + url                                                                          │
│ >  251 │   │   headers = self._auth_headers()                                                                       │
│    252 │   │                                                                                                        │
│    253 │   │   if "content_type" in args["params"]:                                                                 │
│    254 │   │   │   headers["Content-Type"] = args["params"]["content_type"]                                         │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotipy\client.py:242 in _auth_headers      │
│                                                                                                                     │
│    239 │   │   if not self.auth_manager:                                                                            │
│    240 │   │   │   return {}                                                                                        │
│    241 │   │   try:                                                                                                 │
│ >  242 │   │   │   token = self.auth_manager.get_access_token(as_dict=False)                                        │
│    243 │   │   except TypeError:                                                                                    │
│    244 │   │   │   token = self.auth_manager.get_access_token()                                                     │
│    245 │   │   return {"Authorization": f"Bearer {token}"}                                                          │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotipy\oauth2.py:229 in get_access_token   │
│                                                                                                                     │
│    226 │   │   │   if token_info and not self.is_token_expired(token_info):                                         │
│    227 │   │   │   │   return token_info if as_dict else token_info["access_token"]                                 │
│    228 │   │                                                                                                        │
│ >  229 │   │   token_info = self._request_access_token()                                                            │
│    230 │   │   token_info = self._add_custom_values_to_token_info(token_info)                                       │
│    231 │   │   self.cache_handler.save_token_to_cache(token_info)                                                   │
│    232 │   │   return token_info if as_dict else token_info["access_token"]                                         │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotipy\oauth2.py:260 in                    │
│ _request_access_token                                                                                               │
│                                                                                                                     │
│    257 │   │   │   token_info = response.json()                                                                     │
│    258 │   │   │   return token_info                                                                                │
│    259 │   │   except requests.exceptions.HTTPError as http_error:                                                  │
│ >  260 │   │   │   self._handle_oauth_error(http_error)                                                             │
│    261 │                                                                                                            │
│    262 │   def _add_custom_values_to_token_info(self, token_info):                                                  │
│    263 │   │   """                                                                                                  │
│                                                                                                                     │
│ C:\Users\jsnax\AppData\Local\Programs\Python\Python39\lib\site-packages\spotipy\oauth2.py:139 in                    │
│ _handle_oauth_error                                                                                                 │
│                                                                                                                     │
│    136 │   │   │   error = response.text or None                                                                    │
│    137 │   │   │   error_description = None                                                                         │
│    138 │   │                                                                                                        │
│ >  139 │   │   raise SpotifyOauthError(                                                                             │
│    140 │   │   │   f'error: {error}, error_description: {error_description}',                                       │
│    141 │   │   │   error=error,                                                                                     │
│    142 │   │   │   error_description=error_description                                                              │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
SpotifyOauthError: error: invalid_client, error_description: Invalid client
Press any key to continue . . .

Other details

I've used this a couple of months ago with the same playlist and it works. I tried to download it again and it only works for around 600 songs in the beginning and now gives an error.

@jsnaxl jsnaxl added the Bug Unexpected problem or unintended behavior that needs to be fixed label Dec 15, 2024
@jsnaxl
Copy link
Author

jsnaxl commented Dec 16, 2024

Worked around it by creating a new Client ID and Secret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed
Projects
None yet
Development

No branches or pull requests

1 participant