Announcements

Help Wizard

Step 1

NEXT STEP

Auth API Invalid Client: Invalid Redirect URI

Auth API Invalid Client: Invalid Redirect URI

I access Spotify API on my local machine without any problem. I supply to spotify auth request my local address as redirect_uri parameter(http://localhost:8080) and I also added this URI in the Spotify Developer Console to the whitelist.

 

But when I deploy my app to AWS I have a url like this: http://myapp-env.eu-west-2.elasticbeanstalk.com/

 

So I added this url to whitelist on Spotify Developer Console too and sending this url to Spotify authorization request as redirect_uri parameter. But this time spotify returns 'Invalid Client: Invalid Redirect URI' error. Is there something wrong with the AWS url?

 

EDIT: I discovered that when you pass a uri that is whitelisted in the Spotify Developer Console, if the hostname of the machine making the request does not match the host of the uri, spotify returns invalid_redirect_uri.

 

So maybe it's because AWS has load balancing and the hostname of the machine is different than the url above. Is there any way to workaround this?

Reply
1 Reply

I solved it. It's because I forgot to change the redirect uri of the https://accounts.spotify.com/api/authorize request and sent different (although valid) redirect uri in https://accounts.spotify.com/api/token request. The two must match.

 

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random