I am trying to pass multiple scopes to one token in order to have to enter the URL that I was redirected only once. I have created a class Spotify
which inside there I initialize the SpotifyOAuth object
class Spotify():
"""Spotify class that contains plenty of methods to handle your user or retrieve data"""
def __init__(self, cid, secret) -> None:
self.cid = cid
self. Secret = secret
scope = 'user-read-private user-read-recently-played'
# Get the token so we don't need to access every time
token = util.prompt_for_user_token(scope, client_id=self.cid, client_secret=self. Secret)
sp = spotipy.Spotify(auth=token)
self. Username, self.followers, self.id = try_to_login(sp)
self.sp = sp
The scope for user-read-private
seems to work well but when I am trying to call self.sp.current_user_recently_played(limit=50)
I get this error:
return self._get(
File "C:\Users\kyria\AppData\Roaming\Python\Python39\site-packages\spotipy\client.py", line 321, in _get
return self._internal_call("GET", url, payload, kwargs)
File "C:\Users\kyria\AppData\Roaming\Python\Python39\site-packages\spotipy\client.py", line 291, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 403, code:-1 - https://api.spotify.com/v1/me/player/recently-played?limit=50:
Insufficient client scope, reason: None
I tried to define the scope according to here as you can see in the code and also in form of scope = 'user-read-private,user-read-recently-played'
and scope = ['user-read-private', 'user-read-recently-played']
according to the official documentation.
How can I achieve of working with multiple scopes at one SpotifyOAuth object if none of these 3 work?