[GH-ISSUE #444] unable to create playlist #261

Closed
opened 2026-02-27 23:21:40 +03:00 by kerem · 14 comments
Owner

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 :)

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 :)
kerem closed this issue 2026-02-27 23:21:40 +03:00
Author
Owner

@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-.

<!-- gh-comment-id:590886614 --> @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-`.
Author
Owner

@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.

<!-- gh-comment-id:591508603 --> @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.
Author
Owner

@stephanebruckert commented on GitHub (Feb 26, 2020):

When using user_playlist_create can you make sure that you are passing your user ID as the first parameter?

playlists = sp.user_playlist_create(username, playlist_name, description=playlist_description)
                                    ^ must be a user ID 

Spotify user ID. The unique string identifying the Spotify user that you can find at the end of the Spotify URI for the user. The ID of the current user can be obtained via the Web API endpoint.

A convenient way to find the URI is to go to your spotify profile, click share and "copy spotify:uri"

<!-- gh-comment-id:591673203 --> @stephanebruckert commented on GitHub (Feb 26, 2020): When using `user_playlist_create` can you make sure that you are passing your user ID as the first parameter? playlists = sp.user_playlist_create(username, playlist_name, description=playlist_description) ^ must be a user ID > Spotify user ID. The unique string identifying the Spotify user that you can find at the end of the Spotify URI for the user. The ID of the current user can be obtained via the Web API endpoint. A convenient way to find the URI is to go to your spotify profile, click share and "copy spotify:uri"
Author
Owner

@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.`

<!-- gh-comment-id:591701323 --> @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 <module> 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.`
Author
Owner

@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=True to util.prompt_for_user_token, like this:

token = util.prompt_for_user_token(username, scope, 
                                   show_dialog=True, 
                                   client_id=SPOTIPY_CLIENT_ID,
                                   client_secret=SPOTIPY_CLIENT_SECRET,
                                   redirect_uri=SPOTIPY_REDIRECT_URI)
<!-- gh-comment-id:591704093 --> @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=True` to `util.prompt_for_user_token`, like this: token = util.prompt_for_user_token(username, scope, show_dialog=True, client_id=SPOTIPY_CLIENT_ID, client_secret=SPOTIPY_CLIENT_SECRET, redirect_uri=SPOTIPY_REDIRECT_URI)
Author
Owner

@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. :/

spotipy.client.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/users/krishangpatney/playlists:
 You cannot create a playlist for another user.
<!-- gh-comment-id:591705402 --> @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. :/ ``` spotipy.client.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/users/krishangpatney/playlists: You cannot create a playlist for another user. ```
Author
Owner

@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)?

<!-- gh-comment-id:591710401 --> @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)?
Author
Owner

@krishangpatney commented on GitHub (Feb 27, 2020):

Yep. The other functions work except this one which is weird.

<!-- gh-comment-id:591711069 --> @krishangpatney commented on GitHub (Feb 27, 2020): Yep. The other functions work except this one which is weird.
Author
Owner

@stephanebruckert commented on GitHub (Feb 27, 2020):

Does it work from https://developer.spotify.com/console/post-playlists/ ?

<!-- gh-comment-id:591716189 --> @stephanebruckert commented on GitHub (Feb 27, 2020): Does it work from https://developer.spotify.com/console/post-playlists/ ?
Author
Owner

@krishangpatney commented on GitHub (Feb 28, 2020):

Nope, getting the authentication code doesnt work.

<!-- gh-comment-id:592256628 --> @krishangpatney commented on GitHub (Feb 28, 2020): Nope, getting the authentication code doesnt work.
Author
Owner

@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/

<!-- gh-comment-id:592427138 --> @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/
Author
Owner

@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.

<!-- gh-comment-id:592576189 --> @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.
Author
Owner

@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 username variable for both calls:

     util.prompt_for_user_token(username, ...
     sp.user_playlist_create(username, ...

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

<!-- gh-comment-id:597938205 --> @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 `username` variable for both calls: ``` util.prompt_for_user_token(username, ... ``` ``` sp.user_playlist_create(username, ... ``` 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
Author
Owner

@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

<!-- gh-comment-id:600850672 --> @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
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#261
No description provided.