Invalid redirect URI on spotify auth
Asked Answered
R

10

74

I try to auth user through my app with spotify Web API but I receive this error:

INVALID_CLIENT: Invalid redirect URI

URL:

GET https://accounts.spotify.com/authorize/?client_id=6ae90bf75bf748c8874a75d16682f0c5&response_type=code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&scope=user-read-private%20user-read-email

I cant see where is the problem... Can you help?

Retro answered 5/10, 2015 at 19:32 Comment(0)
G
120

You have to add the redirect URI to the White-list in "My Applications" panel.

e.g http://example.com/callback/

Gambrel answered 5/10, 2015 at 20:24 Comment(6)
Ok, i added the url in the white list but i get the same error.Retro
I forgot to add slash after redirect_uri. Redirect url need to be eq with the url from the white list. Thank you for help mallendeo.Retro
and then what? I am running a CLIENT not a server.Muscadine
Spotify App Panel > Edit Settings > Add URLTeets
Works perfectly!Hallie
If this solution doesn't work, try to reset the navigator cache. It worked for me (I just changed to Chrome Incognito).Oakleil
T
34

app.js:

var redirect_uri = 'http://localhost:8888/callback';

(https://developer.spotify.com/dashboard) Spotify > My application:

http://localhost:8888/callback

Dont forget to save.

Tull answered 17/8, 2017 at 4:12 Comment(2)
This answer is still relevant in 2020 and solved my problem, thank you.Leatrice
"Don't forget to save" You came through Thanks!Trigon
S
7

I ran into a similar issue when authenticated via Authorization Code Flow.

Per the docs The value of this parameter must exactly match the value of redirect_uri supplied when requesting the authorization code. So make sure that the:

  1. redirect_uri that is configured in the dashboard
  2. redirect_uri in the GET https://accounts.spotify.com/authorize
  3. redirect_uri in the POST https://accounts.spotify.com/api/token

is exactly the same or else you will get a INVALID_CLIENT: Invalid redirect URI

Straightaway answered 15/5, 2019 at 23:21 Comment(1)
Ok, but when I click Google login I get back a google auth link and same error appears. Any idea?Johnstone
A
7

Navigate to your Spotify developer dashboard and open the project you are working on.

Next click "edit settings" and look for the redirect URIs field.

Put your redirect URI in the field. ex: http://localhost:8888/callback

Click save.

You should be good

Alfonse answered 25/3, 2020 at 22:31 Comment(0)
J
2

First. You have to be sure that you're using app.js from authorization_code directory.

Second. Be sure you edited app.js. That third line is important.

var client_id = '---'; // Your client id
var client_secret = '---'; // Your secret
var redirect_uri = 'http://localhost:8888/callback'; // Your redirect uri - EXAMPLE
Joesphjoete answered 17/4, 2017 at 14:37 Comment(0)
A
2

I use the SpotifyAPI-NET API wrapper by JohnnyCrazy and was having this problem despite adding the URL I specified in my wrapper call to my white list as specified above.

The browser's address bar should show the redirect URL it is using buried in the middle of the string - I found that it was also making a request with "https://accounts.spotify.com:8000/authorize" as the redirect URL - perhaps the wrapper is making 2 API calls, but I found that only by whitelisting both this URL and the one I was specifying would it work for me.

Accelerometer answered 22/8, 2018 at 13:16 Comment(0)
C
2

This is super specific, so make sure you have exact url in each place.

In my app dashboard on spotify I had: http://localhost:3005/

And my url is: https://accounts.spotify.com/authorize?client_id=XXXXXXXXXXXXXXXXX&response_type=code&redirect_uri=http %3A%2F%2Flocalhost:3005/&scope=user-read-currently-playing%20user-top-read

Note the trailing slash in both places.

Canaigre answered 20/1, 2021 at 10:4 Comment(1)
Thank you for this. Using the url you used worked for me. Using 8888 did not work, as I was calling this from a Jupyter notebook (didn't realize beforehand)!Dildo
L
1

This error also appears when the redirect_uri is missing in the request. I figured that out the hard way due to writing "redirect_url" (with an L) instead.

Took me way too long to figure out. Hopefully this can save someone else some time.

Leaflet answered 24/11, 2019 at 1:7 Comment(0)
H
0

+1 to adding 'http://localhost:8888/callback' to the Redirect URIs list in your App's settings via https://developer.spotify.com/dashboard/applications

It's a shame this is not mentioned on the quick start: https://developer.spotify.com/documentation/web-playback-sdk/quick-start/

Hydrated answered 11/9, 2019 at 14:43 Comment(0)
S
0

Include a path after the first pair of forward slashes. For example: Your app name is My Awesome App The redirect URI may be my-awesome-app-login://callback or awesomeprotocol123://returnafterlogin.

For more information please refer this link Spotify Redirect URI Example

Spiller answered 2/12, 2019 at 5:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.