Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"SpotifyOauthError: error: invalid_request, error_description: code must be supplied" when I input URL

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/')
like image 430
Kevin Tran Avatar asked Feb 01 '26 02:02

Kevin Tran


1 Answers

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.

like image 59
Magnus Avatar answered Feb 03 '26 16:02

Magnus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!