Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
Please see below the most popular frequently asked questions.
Loading article...
Loading faqs...
Please see below the current ongoing issues which are under investigation.
Loading issue...
Loading ongoing issues...
Have you added the redirect URI to the dashboard of your app (and clicked save)?
Thanks Ximzend for taking the time to reply. I did but to no avail.
Traceback (most recent call last):
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/oauth2.py", line 588, in refresh_access_token
response.raise_for_status()
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.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):
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/main.py", line 100, in <module>
getSpotifyData()
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/main.py", line 65, in getSpotifyData
search_result = sp.search(q=song_name)
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/client.py", line 585, in search
return self._get(
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/client.py", line 321, in _get
return self._internal_call("GET", url, payload, kwargs)
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/client.py", line 245, in _internal_call
headers = self._auth_headers()
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/client.py", line 236, in _auth_headers
token = self.auth_manager.get_access_token(as_dict=False)
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/oauth2.py", line 525, in get_access_token
token_info = self.validate_token(self.cache_handler.get_cached_token())
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/oauth2.py", line 380, in validate_token
token_info = self.refresh_access_token(
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/oauth2.py", line 596, in refresh_access_token
self._handle_oauth_error(http_error)
File "/Users/namofuser/PycharmProjects/pythonProject/pythonProject/spotifyProject/venv/lib/python3.10/site-packages/spotipy/oauth2.py", line 146, in _handle_oauth_error
raise SpotifyOauthError(
spotipy.oauth2.SpotifyOauthError: error: invalid_client, error_description: Invalid client
Have you tried deleting the .cache file in the directory you are running your script from?
Also, if you set/name the environment variables as followed, you don't have to specify them in your code anymore:
Then you can just use:
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=SCOPE))
Note: there shouldn't be quotes around the IDs and URI around the values of the environment variables.
Thanks for this. I've cleared the pycharm and browser caches but the error message remains.
Hey there you, Yeah, you! 😁 Welcome - we're glad you joined the Spotify Community! While you here, let's have a fun game…