Skip to content

Instantly share code, notes, and snippets.

@angelabauer
Created October 21, 2020 10:19
Show Gist options
  • Save angelabauer/aff0704750052c739fba85dfa55a72c2 to your computer and use it in GitHub Desktop.
Save angelabauer/aff0704750052c739fba85dfa55a72c2 to your computer and use it in GitHub Desktop.
sp = spotipy.Spotify(
auth_manager=SpotifyOAuth(
scope="playlist-modify-private",
redirect_uri="http://example.com",
client_id=YOUR UNIQUE CLIENT ID,
client_secret= YOUR UNIQUE CLIENT SECRET,
show_dialog=True,
cache_path="token.txt"
)
)
user_id = sp.current_user()["id"]
date = input("Which year do you want to travel to? Type the date in this format YYYY-MM-DD: ")
song_uris = ["The list of", "song URIs", "you got by", "searching Spotify"]
playlist = sp.user_playlist_create(user=user_id, name=f"{date} Billboard 100", public=False)
# print(playlist)
sp.user_playlist_add_tracks(user=user_id, playlist_id=playlist["id"], tracks=song_uris)
@verusus
Copy link

verusus commented Apr 7, 2023

I got this error please help!

spotipy.exceptions.SpotifyException: http status: 403, code:-1 -
You cannot create a playlist for another user., reason: None

@apptesting32
Copy link

I got this error please help!

spotipy.exceptions.SpotifyException: http status: 403, code:-1 - You cannot create a playlist for another user., reason: None

Had the same error,
in:
playlist = sp.user_playlist_create(user=user_id, name=f"{date} Billboard 100", public=False)
I was using the "client_id" instead of the "user_id", make sure you are not mixing the two as well.

@verusus
Copy link

verusus commented Apr 12, 2023

I got this error please help!
spotipy.exceptions.SpotifyException: http status: 403, code:-1 - You cannot create a playlist for another user., reason: None

Had the same error, in: playlist = sp.user_playlist_create(user=user_id, name=f"{date} Billboard 100", public=False) I was using the "client_id" instead of the "user_id", make sure you are not mixing the two as well.

Thank you so much, that was issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment