Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding song to playlist won't work with one specific user (update: 2 users) #1078

Open
noelnic opened this issue Mar 13, 2024 · 1 comment
Open
Labels

Comments

@noelnic
Copy link

noelnic commented Mar 13, 2024

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!

@noelnic noelnic added the bug label Mar 13, 2024
@noelnic noelnic changed the title adding song to playlist won't work with one specific user adding song to playlist won't work with one specific user (update: 2 users) Mar 14, 2024
@dieser-niko
Copy link
Member

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

And btw, please make use of formatting code blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants