I'm doing a project on my headless raspberry pi over SSH. When I run this script on my main PC, it outputs as expected my most recently added songs. When I run it on the pi, it always gives a JSONDecodeError (full error below). I've tried doing this a couple different ways but like I said my device is headless so I need to somehow authenticate on startup and without opening a browser window.
Traceback (most recent call last):
File "./spotipy_test", line 34, in <module>
results = sp.current_user_saved_tracks()
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 1232, in current_user_saved_tracks
return self._get("me/tracks", limit=limit, offset=offset, market=market)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 297, in _get
return self._internal_call("GET", url, payload, kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 221, in _internal_call
headers = self._auth_headers()
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 212, in _auth_headers
token = self.auth_manager.get_access_token(as_dict=False)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 525, in get_access_token
token_info = self.validate_token(self.cache_handler.get_cached_token())
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/cache_handler.py", line 70, in get_cached_token
token_info = json.loads(token_info_string)
File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I'm doing a project on my headless raspberry pi over SSH. When I run this script on my main PC, it outputs as expected my most recently added songs. When I run it on the pi, it always gives a JSONDecodeError (full error below). I've tried doing this a couple different ways but like I said my device is headless so I need to somehow authenticate on startup and without opening a browser window.
Script:
Error: