5

I'm trying to use the Spotipy library to pull user tracks and make a playlist. Each function works individually (getTracks, makePlaylist); however, they require different scopes.

def generate_token(scope):
token = util.prompt_for_user_token(
    username='al321rltkr20p7oftb0i801lk',
    scope=('user-library-read','playlist-modify-private'),
    client_id='0e7ea227ef7d407b8bf47a4c545adb3c',
    client_secret='267e96c4713f46d4885a4ea6a099ead4',
    redirect_uri='http://www.google.com')
return token

This returns the error "AttributeError: 'tuple' object has no attribute 'split'" I also get errors when I try to send the two scopes as a list. Any ideas on how to fix this?

Sophie
  • 63
  • 1
  • 5

1 Answers1

9

scope should be a single string, not a tuple.

scope='user-library-read playlist-modify-private'
mjhm
  • 16,497
  • 10
  • 44
  • 55
  • this doesn't seem to work. I still get 401 - Permissions missing with this when using `'user-read-currently-playing user-library-read user-read-recently-played user-modify-playback-state'` I can use `current_user_playlists()` but not `current_playback`. What am I doing wrong? The permission is granted and I have the correct token for it. – slow Jun 17 '19 at 10:39
  • never mind. `user-read-currently-playing` was not enough. i had to include `user-read-playback-state` to get `current_playback()` to work – slow Jun 17 '19 at 10:54
  • As far as I can see, this produces an `OSError: [Errno 48] Address already in use`. – MikeiLL Jul 11 '20 at 23:40
  • Not sure why I am getting the `OSError`, as on the demo `app.py` the multiple scopes work. I get the error on `spotipy.get_user()` and at the moment am wrapping it in a `try, except OSError` and the application is behaving. – MikeiLL Jul 16 '20 at 20:19