[GH-ISSUE #1078] adding song to playlist won't work with one specific user (update: 2 users) #638

Closed
opened 2026-02-28 00:00:27 +03:00 by kerem · 2 comments
Owner

Originally created by @noelnic on GitHub (Mar 13, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1078

Describe the bug
Hey all! I am trying to build an app, that can add songs to playlists the user owns.
The bizarre is, I tested the code for me and another person and it works as it should.
For another specific user, lets call him bob, it does not work.
I can delete songs from bobs playlist, but I can't add any songs. I run the exactly same code.
Happens with:

Your code

current_playback = sp.current_playback()
data = load_skipped_tracks()
trash_playlist_id = data["trash_playlist_ID"] #json file where I stored a playlist_id
currently_played_song_id = current_song["item"]["id"]

print("trying to add song")
add_song_to_trashplaylist(trash_playlist_id, currently_played_song_id) 
print("successful")

#def add_song_to_trashplaylist(trash_playlist_id, track_id):
    list_of_tracks = [track_id] # also tried this: list_of_tracks = {'uris': [track_id]}
    try:
        sp.playlist_add_items(trash_playlist_id, list_of_tracks)
    except Exception as e:
        print(e)
        print("normal adding did not work, trying replacing instead")
        sp.playlist_replace_items(trash_playlist_id, list_of_tracks) # did work!

Expected behavior
I expect that the song is added to the playlist. I found out I can replace the song to the playlist. I am confused with the "Insufficient client scope" exception, because I got both modify scopes and it works with other users.

Output

trying to add song #print
HTTP Error for POST to https://api.spotify.com/v1/playlists/6i4s8LeNdHgtozUviUDkfz/tracks with Params: {'position': None} returned 403 due to Insufficient client scope
http status: 403, code:-1 - https://api.spotify.com/v1/playlists/6i4s8LeNdHgtozUviUDkfz/tracks:
 Insufficient client scope, reason: None
normal adding did not work, trying replacing instead # print
successful # print

Environment:

  • OS: [Windows 10]
  • Python version [Python 3.10.4]
  • spotipy version [2.23.0]
  • using VSCode

I am relatively new to the space, so I hope I provided everything correctly in the right manner.
Thanks for your time!

Originally created by @noelnic on GitHub (Mar 13, 2024). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1078 **Describe the bug** Hey all! I am trying to build an app, that can add songs to playlists the user owns. The bizarre is, I tested the code for me and another person and it works as it should. For another specific user, lets call him bob, it does not work. I can delete songs from bobs playlist, but I can't add any songs. I run the exactly same code. Happens with: **Your code** ```python3 current_playback = sp.current_playback() data = load_skipped_tracks() trash_playlist_id = data["trash_playlist_ID"] #json file where I stored a playlist_id currently_played_song_id = current_song["item"]["id"] print("trying to add song") add_song_to_trashplaylist(trash_playlist_id, currently_played_song_id) print("successful") #def add_song_to_trashplaylist(trash_playlist_id, track_id): list_of_tracks = [track_id] # also tried this: list_of_tracks = {'uris': [track_id]} try: sp.playlist_add_items(trash_playlist_id, list_of_tracks) except Exception as e: print(e) print("normal adding did not work, trying replacing instead") sp.playlist_replace_items(trash_playlist_id, list_of_tracks) # did work! ``` **Expected behavior** I expect that the song is added to the playlist. I found out I can replace the song to the playlist. I am confused with the "Insufficient client scope" exception, because I got both modify scopes and it works with other users. **Output** ``` trying to add song #print HTTP Error for POST to https://api.spotify.com/v1/playlists/6i4s8LeNdHgtozUviUDkfz/tracks with Params: {'position': None} returned 403 due to Insufficient client scope http status: 403, code:-1 - https://api.spotify.com/v1/playlists/6i4s8LeNdHgtozUviUDkfz/tracks: Insufficient client scope, reason: None normal adding did not work, trying replacing instead # print successful # print ``` **Environment:** - OS: [Windows 10] - Python version [Python 3.10.4] - spotipy version [2.23.0] - using VSCode I am relatively new to the space, so I hope I provided everything correctly in the right manner. Thanks for your time!
kerem 2026-02-28 00:00:27 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@dieser-niko commented on GitHub (May 1, 2024):

Hi, sorry for the late reply. Just to be sure, what are your current scopes?

And btw, please make use of formatting code blocks

<!-- gh-comment-id:2089256262 --> @dieser-niko commented on GitHub (May 1, 2024): Hi, sorry for the late reply. Just to be sure, what are your current scopes? And btw, please make use of [formatting code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks)
Author
Owner

@dieser-niko commented on GitHub (Jul 10, 2024):

Closing as there is no activity or reply from the author.

<!-- gh-comment-id:2220325114 --> @dieser-niko commented on GitHub (Jul 10, 2024): Closing as there is no activity or reply from the author.
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#638
No description provided.