StabDev
StabDev

Reputation: 741

Setting localhost as a Spotify redirect_uri

I've looked here on SO and I've found a few posts about redirect_uri but I can't seem to figure out how I use Localhost as my redirect uri . Hopefully anyone can explain this to me.

With kind regards,

Upvotes: 11

Views: 23700

Answers (4)

Manish Doley
Manish Doley

Reputation: 1

The docs given in spotify are wrong Once you hit 'Sign in with Spotify' check the networks tab and in the payload check for 'redirect_uri'. Copy and paste this uri inside your Spotify Dashboard settings for redirect uri

Hope it helps

Upvotes: 0

user3368767
user3368767

Reputation: 11

After failing to find any proper explanation on request URI, I found out that redirect_uri is just a URL where Spotify responds back with parameter code for user to access the authorized user’s account. I provided a GET mapping URL as a callback, and Spotify responds back with:

www.example.com/callback?code="code to access user account"

(Make sure to whitelist your callback URL.)

Upvotes: 0

In addition to what is described in the Spotify tutorial, you also have to whitelist your redirect URI as explained here:

Whitelist a Redirect URI

In Redirect URIs enter one or more addresses that you want to whitelist with Spotify. This URI enables the Spotify authentication service to automatically re-launch your app every time the user logs in.

To whitelist your rediret URI: Go to https://developer.spotify.com/dashboard -> select your application -> Edit settings -> Add Redirect URIs

For the tutorial to work, you can add http://localhost:8888/callback to the whitelisted URIs

Upvotes: 10

José M. Pérez
José M. Pérez

Reputation: 3279

You can follow the steps described in the Spotify's Web API Beginner's Tutorial, which runs a local server and uses localhost as part of the redirect_uri.

Localhost URLs are valid as redirect_uri and useful for development purposes, though once you make your project public you will need to switch to a URL with a custom domain or IP so the request reaches your server.

What I normally do is to set up two redirect_uris, one with localhost and another one with a domain. Then in your code you use one or the other depending on the hostname. You can see an example.

Upvotes: 5

Related Questions