mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #549] I get error spotipy.oauth2.SpotifyOauthError: You must either set a cache_path or a username. #330
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#330
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vikivanov on GitHub (Jul 26, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/549
Describe the bug
When I try to run my script I get the following error: spotipy.oauth2.SpotifyOauthError: You must either set a cache_path or a username.
Your code
scope = 'playlist-modify-public'
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
sp.user_playlist_create(username_id, 'YouTube Converter PL', public=True, description='Test')
Expected behavior
I want to create a playlist. I tried calling other methods with sp but get the same error for all.
Output
File "D:/MyProjects/YTtoSpotify/convert.py", line 58, in create_spotify_playlist
sp.user_playlist_create(username_id, 'YouTube Converter PL', public=True, description='Test')
File "C:\Users\Acer\AppData\Roaming\Python\Python38\site-packages\spotipy\client.py", line 628, in user_playlist_create
return self._post("users/%s/playlists" % (user,), payload=data)
File "C:\Users\Acer\AppData\Roaming\Python\Python38\site-packages\spotipy\client.py", line 215, in _post
return self._internal_call("POST", url, payload, kwargs)
File "C:\Users\Acer\AppData\Roaming\Python\Python38\site-packages\spotipy\client.py", line 154, in _internal_call
headers = self._auth_headers()
File "C:\Users\Acer\AppData\Roaming\Python\Python38\site-packages\spotipy\client.py", line 145, in _auth_headers
token = self.auth_manager.get_access_token(as_dict=False)
File "C:\Users\Acer\AppData\Roaming\Python\Python38\site-packages\spotipy\oauth2.py", line 448, in get_access_token
token_info = self.get_cached_token()
File "C:\Users\Acer\AppData\Roaming\Python\Python38\site-packages\spotipy\oauth2.py", line 275, in get_cached_token
raise SpotifyOauthError(
spotipy.oauth2.SpotifyOauthError: You must either set a cache_path or a username.
Environment:
@vikivanov commented on GitHub (Jul 27, 2020):
Managed to go around this by passing in cache_path and redirect_uri:
Now the code works and creates a playlist in my profile.
@stephanebruckert commented on GitHub (Aug 30, 2020):
Fixed in https://github.com/plamere/spotipy/pull/567