1
votes

I currently have a python script implemented using the Spotipy python library based on the Spotify API. However, I would like to make it accessible to more users who wouldn't have their own CLIENT_ID, CLIENT_SECRET etc. How could I do this? I'm currently using Authorization Code Flow and when a different user logs in, it raises an exception and says 'You cannot create a playlist for another user." Thanks.

2
Welcome to SO! You might take the Tour and you should (re-)read the help topic How to Ask to get a feeling on how to contribute. You should at least provide a minimal, complete and reproducible example (MCRE) of your code.stackprotector

2 Answers

2
votes

One possibility is to make it an API and host it as part of a python web server. Here is a full working example that would allow multiple users to sign in https://github.com/plamere/spotipy/blob/master/examples/app.py.

It uses Flask but you could adapt it to Django, for example.

0
votes

You will have to provide correct scope parameter during authorization flow (below is the basic example in node.js). Scope basically defines what all permissions you have requested from the end user.

app.get('/login', function(req, res) {
var scopes = 'user-read-private user-read-email';
res.redirect('https://accounts.spotify.com/authorize' +
  '?response_type=code' +
  '&client_id=' + my_client_id +
  (scopes ? '&scope=' + encodeURIComponent(scopes) : '') +
  '&redirect_uri=' + encodeURIComponent(redirect_uri));
});

Snippet referenced from here.

Also, check the list of scopes and their description here. If you do not find appropriate scope for your purpose, unfortunately, it's a blocker for you.