[GH-ISSUE #1026] JSONDecodeError when trying to pull playlists #612

Closed
opened 2026-02-28 00:00:16 +03:00 by kerem · 1 comment
Owner

Originally created by @whoishe1 on GitHub (Sep 2, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1026

Hi,

I am using the user authentication quick start instructions to try to get my current playlists and other information, but currently running into a JSONDecodeError error. I have doubled checked my creds in the Spotify dev console.

Code:

import spotipy
from spotipy.oauth2 import SpotifyOAuth

YOUR_APP_CLIENT_ID = "myappclientid"
YOUR_APP_CLIENT_SECRET = "myclientsecret"
YOUR_APP_REDIRECT_URI = "mycallback"
SCOPE = "playlist-read-private"

sp = spotipy.Spotify(
    auth_manager=SpotifyOAuth(
        client_id=YOUR_APP_CLIENT_ID,
        client_secret=YOUR_APP_CLIENT_SECRET,
        redirect_uri=YOUR_APP_REDIRECT_URI,
        scope=SCOPE,
    )
)

sp.current_user_playlists(limit = 50)

trackback message:

JSONDecodeError                           Traceback (most recent call last)
c:\my_spotify_playlists\example.py in 
     14 )
     15 
---> 16 sp.current_user_playlists(limit = 50)

c:\Users\MyUserName\AppData\Local\Programs\Python\Python38\lib\site-packages\spotipy\client.py in current_user_playlists(self, limit, offset)
    635                 - offset - the index of the first item to return
    636         """
--> 637         return self._get("me/playlists", limit=limit, offset=offset)
    638 
    639     def playlist(self, playlist_id, fields=None, market=None, additional_types=("track",)):

c:\Users\MyUserName\AppData\Local\Programs\Python\Python38\lib\site-packages\spotipy\client.py in _get(self, url, args, payload, **kwargs)
    321             kwargs.update(args)
    322 
--> 323         return self._internal_call("GET", url, payload, kwargs)
    324 
    325     def _post(self, url, args=None, payload=None, **kwargs):

c:\Users\MyUserName\AppData\Local\Programs\Python\Python38\lib\site-packages\spotipy\client.py in _internal_call(self, method, url, payload, params)
    245         if not url.startswith("http"):
    246             url = self.prefix + url
--> 247         headers = self._auth_headers()
    248 
    249         if "content_type" in args["params"]:
...
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Environment:

  • OS: Windows 10
  • Python Version: 3.8.10
  • spotipy version: 2.23
  • IDE: VSCode
Originally created by @whoishe1 on GitHub (Sep 2, 2023). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1026 Hi, I am using the `user authentication` quick start instructions to try to get my current playlists and other information, but currently running into a JSONDecodeError error. I have doubled checked my creds in the Spotify dev console. **Code:** ``` import spotipy from spotipy.oauth2 import SpotifyOAuth YOUR_APP_CLIENT_ID = "myappclientid" YOUR_APP_CLIENT_SECRET = "myclientsecret" YOUR_APP_REDIRECT_URI = "mycallback" SCOPE = "playlist-read-private" sp = spotipy.Spotify( auth_manager=SpotifyOAuth( client_id=YOUR_APP_CLIENT_ID, client_secret=YOUR_APP_CLIENT_SECRET, redirect_uri=YOUR_APP_REDIRECT_URI, scope=SCOPE, ) ) sp.current_user_playlists(limit = 50) ``` **trackback message:** ```--------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last) c:\my_spotify_playlists\example.py in 14 ) 15 ---> 16 sp.current_user_playlists(limit = 50) c:\Users\MyUserName\AppData\Local\Programs\Python\Python38\lib\site-packages\spotipy\client.py in current_user_playlists(self, limit, offset) 635 - offset - the index of the first item to return 636 """ --> 637 return self._get("me/playlists", limit=limit, offset=offset) 638 639 def playlist(self, playlist_id, fields=None, market=None, additional_types=("track",)): c:\Users\MyUserName\AppData\Local\Programs\Python\Python38\lib\site-packages\spotipy\client.py in _get(self, url, args, payload, **kwargs) 321 kwargs.update(args) 322 --> 323 return self._internal_call("GET", url, payload, kwargs) 324 325 def _post(self, url, args=None, payload=None, **kwargs): c:\Users\MyUserName\AppData\Local\Programs\Python\Python38\lib\site-packages\spotipy\client.py in _internal_call(self, method, url, payload, params) 245 if not url.startswith("http"): 246 url = self.prefix + url --> 247 headers = self._auth_headers() 248 249 if "content_type" in args["params"]: ... 354 except StopIteration as err: --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None 356 return obj, end JSONDecodeError: Expecting value: line 1 column 1 (char 0) ``` **Environment:** - OS: Windows 10 - Python Version: 3.8.10 - spotipy version: 2.23 - IDE: VSCode
kerem 2026-02-28 00:00:16 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@whoishe1 commented on GitHub (Sep 2, 2023):

deleting .cache file fixed my issue.

<!-- gh-comment-id:1703965345 --> @whoishe1 commented on GitHub (Sep 2, 2023): deleting .cache file fixed my issue.
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/spotipy#612
No description provided.