"Oops! Something went wrong" when trying to get spotipy token

950 views Asked by At

I'm trying to access my library using spotipy and have the following code:

import spotipy
import spotipy.util as util


clientid = 'myid'
clientsecret = 'mysecret'
username = 'myname'
scopes = 'user-library-modify playlist-modify-private'
redirect = 'localhost:8888/callback'


def getToken(SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, username, scope, redirect):

    token = util.prompt_for_user_token(username,
                                    scope,
                                    client_id=SPOTIPY_CLIENT_ID,
                                    client_secret=SPOTIPY_CLIENT_SECRET,
                                    redirect_uri=redirect)

    if token:
        print('Token successfully obtained!')
        return token
    else:
        print('Failed to get token!')
        return 0



getToken(clientid, clientsecret, username, scopes, redirect)

This does one of two things: It will open up another browser window and give an option to click "Okay" or "Cancel", neither of which does anything when I click them; or it will give me the following error:

enter image description here

The Enter the URL you were redirected to: prompt that I get seems to throw a Bad Request error whenever I try to put in either my redirect url as defined above or URL I'm directed to, with the Client ID and Client Secret verbatim.

Any help is appreciated.

0

There are 0 answers