Announcements

Making application work for different users(Spotify API)

Making application work for different users(Spotify API)

Luks_ger

Hi, I currently have a python script that creates a playlist of recently played tracks. However, it only works for my own account right now and I wanted to know how I could make this work for other users as well. I have the appropriate scopes (playlist-modify-public and user-read-recently-played) included and I am using Authorization Code Flow. When a different user logs in, it returns 403 and says "You cannot create playlists for another user". Thanks

Reply
3 Replies

Hubo

Hey @Luks_ger, thanks for coming to the Community for help!

Sounds like an exciting project! Let's see what could be going on here. In the API call you need to specify the user-id (username) of the user you're making a playlist for. 

 

https://api.spotify.com/v1/users/{user_id}/playlists

 

Could you make sure this is set as a variable and not hard-coded? Let me know if that works! 🙂

 

Have a good one, happy coding!

Hubo

HuboSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Luks_ger

The program gets the username as a command line argument so it's not hardcoded. It might be something with how the Spotipy python library I'm using might be implemented. I'm using two different types of API calls. One make a v1/me/ request while the other makes a v1/user/{username}/ call. I don't know if this could be the problem.

Hubo

Hey @Luks_ger, thanks for getting back to me here!

 

Hmm, this may sound a bit odd, but could you restart your device? That could help here. Let me know how you get on!

 

Have a good one,

Hubo

HuboSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Suggested posts

Env: prod