mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #444] unable to create playlist #261
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#261
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 @krishangpatney on GitHub (Feb 24, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/444
So I've authenticated my user however I'm still getting the error where it says I'm unable to create a playlist for another user :
spotipy.client.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/users/krishangpatney/playlists:
You cannot create a playlist for another user.
any help would be appreciated.
Thanks :)
@stephanebruckert commented on GitHub (Feb 25, 2020):
Can you please share a minimal working code?
It's very likely your token belongs to another user than krishangpatney. Try to remove the token from your project, the file starts with
.cache-.@krishangpatney commented on GitHub (Feb 26, 2020):
`
playlist_name = "TrialOne"
playlist_description = 'this is me first trial lmao'
scope = "playlist-modify-public"
token = util.prompt_for_user_token(username, scope, client_id=SPOTIPY_CLIENT_ID, client_secret=SPOTIPY_CLIENT_SECRET, redirect_uri=SPOTIPY_REDIRECT_URI)
if token:
sp = spotipy.Spotify(auth=token)
sp.trace = False
playlists = sp.user_playlist_create(username, playlist_name,
description=playlist_description)
pprint.pprint(playlists)
else:
print("Can't get token for", username)`
So looking at the tokens created when I add tracks to an already created playlist its making two, one with the wrong name and one with the correct name spelling, which is confusing and thats my code, technically should work.
@stephanebruckert commented on GitHub (Feb 26, 2020):
When using
user_playlist_createcan you make sure that you are passing your user ID as the first parameter?A convenient way to find the URI is to go to your spotify profile, click share and "copy spotify:uri"
@krishangpatney commented on GitHub (Feb 26, 2020):
just tried that and it's still not letting me use it. `
Traceback (most recent call last):
File "C:\Users\krish\Anaconda3\envs\spotify\lib\site-packages\spotipy\client.py", line 163, in _internal_call
r.raise_for_status()
File "C:\Users\krish\Anaconda3\envs\spotify\lib\site-packages\requests\models.py", line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/users/krishangpatney/playlists
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "createplaylist.py", line 50, in
description=playlist_description)
File "C:\Users\krish\Anaconda3\envs\spotify\lib\site-packages\spotipy\client.py", line 549, in user_playlist_create
return self._post("users/%s/playlists" % (user,), payload=data)
File "C:\Users\krish\Anaconda3\envs\spotify\lib\site-packages\spotipy\client.py", line 227, in _post
return self._internal_call("POST", url, payload, kwargs)
File "C:\Users\krish\Anaconda3\envs\spotify\lib\site-packages\spotipy\client.py", line 173, in _internal_call
headers=r.headers,
spotipy.client.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/users/krishangpatney/playlists:
You cannot create a playlist for another user.`
@stephanebruckert commented on GitHub (Feb 26, 2020):
Did you sign in with a different user previously? I suspect you are not signed in under the correct user.
Can you try to add
show_dialog=Truetoutil.prompt_for_user_token, like this:@krishangpatney commented on GitHub (Feb 26, 2020):
Well, I only have one user account and with the show_dialog enabled it's still giving me the same error. :/
@stephanebruckert commented on GitHub (Feb 27, 2020):
That's weird, I'm running out of ideas.
Are you running the latest version of spotipy (2.9.0)?
@krishangpatney commented on GitHub (Feb 27, 2020):
Yep. The other functions work except this one which is weird.
@stephanebruckert commented on GitHub (Feb 27, 2020):
Does it work from https://developer.spotify.com/console/post-playlists/ ?
@krishangpatney commented on GitHub (Feb 28, 2020):
Nope, getting the authentication code doesnt work.
@stephanebruckert commented on GitHub (Feb 28, 2020):
How, is there an error message? What browser are you using? Can you try to clear your cache or just try in a different browser?
If this still doesn't work, you should absolutely post that issue in https://github.com/spotify/web-api/
@krishangpatney commented on GitHub (Feb 28, 2020):
I tried it out with firefox and chrome, going to post the issue since it's still not working. Thank you for you help.
@stephanebruckert commented on GitHub (Mar 11, 2020):
Hey @krishangpatney,
Previously you said that even from https://developer.spotify.com/console/post-playlists/ you couldn't post a playlist. Now it looks like you can according to https://github.com/spotify/web-api/issues/1486, is this right?
Now to make it work from Python I suggest that you start from a clean environment. Did you already delete the token from your project folder? There should be a hidden file that sits close to your code, it should be named
.cache-{username}. Please confirm you managed to delete it and try again.Then there is something else we haven't tried: make sure you use the same
usernamevariable for both calls:The username is your ID and it is probably not
krishangpatney, instead it should look like either a number 12345678 or a weird sequence of characters xlq3jsovp49eg9go8ifd@stephanebruckert commented on GitHub (Mar 18, 2020):
Closing this for now as it's hard to define what the issue really is but please feel free to reopen with more details