Reputation: 31
Down below is my code. I'm trying to get a token so I can authenticate. Having a problem because I'm not being redirected to another URL. I've already inputted the URI into my Spotify developer app. Not sure what's wrong or if I'm inputting the URL incorrectly. Inputting as: https://www.google.com/ . Also, currently using google collab if that makes a difference.
#client id and secret for my application
client_id = 'id' # hidden for now
client_secret= 'secret' # hidden for now
scope = 'user-library-read'
if len(sys.argv) > 1:
username = sys.argv[1]
else:
print("Usage: %s username" % (sys.argv[0],))
sys.exit()
auth_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret)
sp = spotipy.Spotify(auth_manager=auth_manager)
token = util.prompt_for_user_token(username, scope, client_id= client_id, client_secret=client_secret, redirect_uri='https://www.google.com/')
Upvotes: 3
Views: 5370
Reputation: 1
I had the same issue. If you want to get Spotify user data, you have to let the user login and authorize access by a browser.
Google collab won't open a browser. Instead it shows a URL input field. But the URL should contain an auth code which is generated by spotify.
So, I ran my code in local. It opened a browser to let me authorize it. Everything worked.
This is the situation I encountered, hoping it can help someone.
Upvotes: 0
Reputation: 81
I had the same issue, although when trying to access my library.
I eventually read the documentation very thoroughly and found the paragraph:
The redirect_uri argument or SPOTIPY_REDIRECT_URI environment variable must match the redirect URI added to your application in your Dashboard. The redirect URI can be any valid URI (it does not need to be accessible) such as http://example.com, http://localhost or http://127.0.0.1:9090.
My problem was that I hadn't added the redirect URI to my app on the Developer Dashboard. Make sure these are the same for your application too and hopefully it will solve your issue.
Upvotes: 1