pythonflaskspotipy

Spotipy current_user_playlists() only returns playlists that are on the public profile


I'm trying to access all the playlists from a user, the ones created, and followed, but when I use sp.current_user_playlists() it only gives me the playlists that have been added to public profile, when I removed them no playlists were returned.

Here is my code:

def getPlaylists():
    session[TOKEN_INFO], authorized = get_token()
    session.modified = True
    
    if not authorized:
        return redirect('/')
    sp = spotipy.Spotify(auth=session.get('token_info').get('access_token'))
    return sp.current_user_playlists()

and this is the auth I'm using:

def create_oauth():
    return SpotifyOAuth(
        client_id=client_id,
        client_secret=client_secret,
        redirect_uri=url_for('redirectPage', _external=True),
        scope='playlist-read-private'
    )

Solution

  • You need to modify your create_oauth() function, this way:

    def create_oauth():
        return SpotifyOAuth(
            client_id=client_id,
            client_secret=client_secret,
            redirect_uri=url_for('redirectPage', _external=True),
            scope='playlist-read-private playlist-read-collaborative'
        )