2

Im am using a family account (premium) and this code returns a'Premium required' error. My code is as follows:


device_id = '0d1841b0976bae2a3a310dd74c0f3df354899bc8'

def playSpotify():

    client_credentials_manager = SpotifyClientCredentials(client_id='<REDACTED>', client_secret='<REDACTED>')
    sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)

    playlists = sp.user_playlists('gh8gflxedxmp4tv2he2gp92ev')

    #while playlists:
        #for i, playlist in enumerate(playlists['items']):
            #print("%4d %s %s" % (i + 1 + playlists['offset'], playlist['uri'],  playlist['name']))
        #if playlists['next']:
            #playlists = sp.next(playlists)
        #else:
            #playlists = None




    #sp.shuffle(true, device_id=device_id)
    #sp.repeat(true, device_id=device_id)
    sp.start_playback(device_id=device_id, context_uri='spotify:playlist:4ndG2qFEFt1YYcHYt3krjv')


Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130
Zotec
  • 51
  • 5

1 Answers1

0

When using SpotifyClientCredentials the token that is generated doesn't belong to any user but to an app, hence the error message.

What you need to do is use SpotifyOAuth instead. So to initialize spotipy, just do:

sp = spotipy.Spotify(auth_manager=spotipy.SpotifyOAuth())

This will open a browser tab and require you to sign in to your account.

Stéphane Bruckert
  • 21,706
  • 14
  • 92
  • 130