1

I am trying to access Spotify playlists using the spotipy and pbl libraries. See http://pbl.readthedocs.io/en/latest/ for the latter.

I have this:

import sys
from pbl import *
import spotipy
import spotipy.util as util


def fetch(): #pbl methods here

    classic_rock = Sample(PlaylistSource('Rock Classics'), sample_size=10)
    new_music = Sample(PlaylistSource('New Music Tuesday'), sample_size=5)
    combined = Shuffler(Concatenate([classic_rock, new_music]))
    show_source(combined)

scope = 'playlist-modify-public'

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, client_id='a_valid_id', client_secret='a_valid_secret', redirect_uri='http://localhost:8888/callback')

if token:
    sp = spotipy.Spotify(auth=token)
    fetch()

If I bypass the snippet relative to pbl methods and the pbl function call above and proceed, I am granted access.

    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

Otherwise access is denied, and I get spotipy.oauth2.SpotifyOauthError: No client id

What is going on here?

halfer
  • 19,824
  • 17
  • 99
  • 186
8-Bit Borges
  • 9,643
  • 29
  • 101
  • 198
  • I'm going to ask the obvious. Did you create an application on https://developer.spotify.com/my-applications, added the needed redirect_uri and replaced the `client_id` and `client_secret` in your code? – José M. Pérez Jun 07 '16 at 20:14
  • @JoséM.Pérez sure! that's what I mean by "a_valid_id". – 8-Bit Borges Jun 08 '16 at 00:41

0 Answers0