[GH-ISSUE #484] 'User_Playlist_Create' is throwing the '403' error #285

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

Originally created by @jboss10 on GitHub (Apr 27, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/484

Hi Guys -

Maybe I'm doing something wrong but I successfully created authorization/authentication and can pull and parse songs/album from (2) test playlists I created. However, I'm not able to create a playlist?
Error I'm seeing:
ERROR:spotipy.client:HTTP Error for POST to https://api.spotify.com/v1/users/MYUSRNAME/playlists returned 403 due to You cannot create a playlist for another user.
Traceback (most recent call last):
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/users/MYUSRNAME/playlists

Why is it telling me I'm attempting to create a playlist for another user?

Here is my authorization routine. Also note, I've changed the scope to 'private' and 'public' with no success. I added the 'user_playlist_create' routine in this method just as a test and still fails.

def executeAuthorization(self):
        # Attempt authorization and store our token
        try:
            self.token = util.prompt_for_user_token(self.usrName,
                                                    scope='user-library-read playlist-modify-private',
                                                    client_id = self.clientID,
                                                    client_secret = self.clientSecret,
                                                    redirect_uri = self.redirectURI)

        except:
            os.remove(f".cache-{'username'}")   
            self.token = util.prompt_for_user_token(self.usrName,
                                                    scope='user-library-read playlist-modify-private',
                                                    client_id = self.clientID ,
                                                    client_secret = self.clientSecret,
                                                    redirect_uri = self.redirectURI)

        # Create/store the 'sp' object
        self.sp = spotipy.Spotify(auth = self.token)
        self.sp.user_playlist_create(self.usrName, "Test", public = False)
Originally created by @jboss10 on GitHub (Apr 27, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/484 Hi Guys - Maybe I'm doing something wrong but I successfully created authorization/authentication and can pull and parse songs/album from (2) test playlists I created. However, I'm not able to create a playlist? Error I'm seeing: ERROR:spotipy.client:HTTP Error for POST to https://api.spotify.com/v1/users/MYUSRNAME/playlists returned 403 due to You cannot create a playlist for another user. Traceback (most recent call last): raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.spotify.com/v1/users/MYUSRNAME/playlists Why is it telling me I'm attempting to create a playlist for another user? Here is my authorization routine. Also note, I've changed the scope to 'private' and 'public' with no success. I added the 'user_playlist_create' routine in this method just as a test and still fails. ```python def executeAuthorization(self): # Attempt authorization and store our token try: self.token = util.prompt_for_user_token(self.usrName, scope='user-library-read playlist-modify-private', client_id = self.clientID, client_secret = self.clientSecret, redirect_uri = self.redirectURI) except: os.remove(f".cache-{'username'}") self.token = util.prompt_for_user_token(self.usrName, scope='user-library-read playlist-modify-private', client_id = self.clientID , client_secret = self.clientSecret, redirect_uri = self.redirectURI) # Create/store the 'sp' object self.sp = spotipy.Spotify(auth = self.token) self.sp.user_playlist_create(self.usrName, "Test", public = False) ```
kerem 2026-02-27 23:21:47 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

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

In your browser, your connected spotify user is probably not the same one as self.usrName. To change user, add show_dialog=True as suggested here https://github.com/plamere/spotipy/issues/451#issuecomment-597794047.

Then, check that sp.me() returns the correct user, see https://github.com/plamere/spotipy/issues/464#issuecomment-609411128

<!-- gh-comment-id:620095722 --> @stephanebruckert commented on GitHub (Apr 27, 2020): In your browser, your connected spotify user is probably not the same one as `self.usrName`. To change user, add `show_dialog=True` as suggested here https://github.com/plamere/spotipy/issues/451#issuecomment-597794047. Then, check that `sp.me()` returns the correct user, see https://github.com/plamere/spotipy/issues/464#issuecomment-609411128
Author
Owner

@jboss10 commented on GitHub (Apr 27, 2020):

Great, I’ll give it a shot and report back. Thanks a bunch!

Why does the self.usrName work when getting the songs from my playlist? Just curious.

<!-- gh-comment-id:620150398 --> @jboss10 commented on GitHub (Apr 27, 2020): Great, I’ll give it a shot and report back. Thanks a bunch! Why does the ``self.usrName`` work when getting the songs from my playlist? Just curious.
Author
Owner

@ritiek commented on GitHub (Apr 27, 2020):

Why does the self.usrName work when getting the songs from my playlist? Just curious.

I'm assuming you're using the methods Spotify.user_playlist or Spotify.user_playlist_tracks. That's probably because Spotify removed the necessity of passing the username for fetching playlists some time ago. See #335. You could pass any username (or None) and it should still work.

spotipy hasn't omitted the user parameter from existing methods yet since this change wouldn't be backwards compatible with older spotipy versions. You could however use the newer methods Spotify.playlist and Spotify.playlist_tracks which do not require the user parameter.

<!-- gh-comment-id:620173622 --> @ritiek commented on GitHub (Apr 27, 2020): > Why does the ``self.usrName`` work when getting the songs from my playlist? Just curious. I'm assuming you're using the methods [`Spotify.user_playlist`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist) or [`Spotify.user_playlist_tracks`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist_tracks). That's probably because Spotify removed the necessity of passing the username for [fetching playlists](https://developer.spotify.com/documentation/web-api/reference/playlists/get-playlist/) some time ago. See #335. You could pass any username (or `None`) and it should still work. spotipy hasn't omitted the `user` parameter from existing methods yet since this change wouldn't be backwards compatible with older spotipy versions. You could however use the newer methods [`Spotify.playlist`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.playlist) and [`Spotify.playlist_tracks`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.playlist_tracks) which do not require the `user` parameter.
Author
Owner

@jboss10 commented on GitHub (Apr 27, 2020):

Yes, 100% that's what it was. Looks like I was trying to connect to my personal account and not my test environment. DUH!

This is a project so could someone run into this issue when running/testing my script? If so, how to avoid from them using their own personal sign-in?

Thanks!

<!-- gh-comment-id:620250461 --> @jboss10 commented on GitHub (Apr 27, 2020): Yes, 100% that's what it was. Looks like I was trying to connect to my personal account and not my test environment. DUH! This is a project so could someone run into this issue when running/testing my script? If so, how to avoid from them using their own personal sign-in? Thanks!
Author
Owner

@jboss10 commented on GitHub (Apr 27, 2020):

Why does the self.usrName work when getting the songs from my playlist? Just curious.

I'm assuming you're using the methods Spotify.user_playlist or Spotify.user_playlist_tracks. That's probably because Spotify removed the necessity of passing the username for fetching playlists some time ago. See #335. You could pass any username (or None) and it should still work.

spotipy hasn't omitted the user parameter from existing methods yet since this change wouldn't be backwards compatible with older spotipy versions. You could however use the newer methods Spotify.playlist and Spotify.playlist_tracks which do not require the user parameter.

Ah, OK - great! Thanks so much!

<!-- gh-comment-id:620250807 --> @jboss10 commented on GitHub (Apr 27, 2020): > > Why does the `self.usrName` work when getting the songs from my playlist? Just curious. > > I'm assuming you're using the methods [`Spotify.user_playlist`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist) or [`Spotify.user_playlist_tracks`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.user_playlist_tracks). That's probably because Spotify removed the necessity of passing the username for [fetching playlists](https://developer.spotify.com/documentation/web-api/reference/playlists/get-playlist/) some time ago. See #335. You could pass any username (or `None`) and it should still work. > > spotipy hasn't omitted the `user` parameter from existing methods yet since this change wouldn't be backwards compatible with older spotipy versions. You could however use the newer methods [`Spotify.playlist`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.playlist) and [`Spotify.playlist_tracks`](https://spotipy.readthedocs.io/en/2.12.0/#spotipy.client.Spotify.playlist_tracks) which do not require the `user` parameter. Ah, OK - great! Thanks so much!
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#285
No description provided.