1

I am trying to authenticate my python app to a specific user using spotipy. I have done this before with a few other users with no problems. This user however each time I try I keep getting '{"error":"invalid_grant","error_description":"Invalid authorization code"}'

I have also tried manually a couple different ways including curl:

curl -H "Authorization: Basic OTQxNDliNjI3...WRhMzk5YTY2ZTliZWY=" -d grant_type=authorization_code -d code=AQByvdq4Vr9-L_ZLrySeTOx...pm1vmb8vwGe2GUXcmTY#= -d redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Fcallback https://accounts.spotify.com/api/token {"error":"invalid_grant","error_description":"Invalid authorization code"}

I have tried both putting the client_code and client_secret in the header (as shown above) and in the post body both with the same error

keep in mind I am using the exact code I get from my callback url as soon as I can (cut and paste) and like I said before, this method has worked with other users with no problems. Can anyone think of anything else I can try?

Jared Wilkin
  • 231
  • 3
  • 12
  • After trial and error I discovered that apparently the "#" and everything after it is NOT part of the code. Spotipy doesn't properly parse this and my cut and paste didn't either. When trying the code without the "#" it worked just fine – Jared Wilkin May 13 '16 at 15:56

1 Answers1

1

Spotipy currently has a bug where it doesn't correctly parse out the code from a given redirect_uri if that uri contains a trailing "#" segment. When spotipy propmts for you to paste in the redirect_uri do so by copying the uri without including the "#" and everything following it

Jared Wilkin
  • 231
  • 3
  • 12