My question is: is possible using two or more scopes in the same time with WebAPI Spotify (in particular Spotipy)? For example to use the scopes 'user-modify-playback-state' and 'user-library-read'
Thanks
My question is: is possible using two or more scopes in the same time with WebAPI Spotify (in particular Spotipy)? For example to use the scopes 'user-modify-playback-state' and 'user-library-read'
Thanks
You can use multiple scopes when accessing the Spotify API. I've not worked directly with Spotipy
but if it's similar to the packages I've used you can do the following (for example):
import sys
import spotipy
import spotipy.util as util
scope = 'user-library-read user-modify-playback-state'
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print "Usage: %s username" % (sys.argv[0],)
sys.exit()
token = util.prompt_for_user_token(username, scope)
if token:
sp = spotipy.Spotify(auth=token)
results = sp.current_user_saved_tracks()
for item in results['items']:
track = item['track']
print track['name'] + ' - ' + track['artists'][0]['name']
else:
print "Can't get token for", username
That example is taken from https://spotipy.readthedocs.io/en/latest/#authorized-requests and adapted for >1 scope.
Note: if your users are auth'd with a different scope then you will need to get them to re-auth your app in order to gain access to further scope via a new token/refresh token.