Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,

like image 371
StabDev Avatar asked Jul 05 '16 07:07

StabDev


People also ask

How do I make my Spotify URL redirect?

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. Click save.

What should be the redirect URI in Spotify?

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 .

What is invalid redirect URI?

Invalid Redirect URI While working on a web based client, you have to ensure that the redirect URI passed while authentication, is the same as the one given during registration. If the redirect uri is not the one given during registration, an invalid redirect uri error will be thrown.


2 Answers

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

like image 93
Juan Manuel Fernández Caeiro Avatar answered Sep 18 '22 22:09

Juan Manuel Fernández Caeiro


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.

like image 41
José M. Pérez Avatar answered Sep 22 '22 22:09

José M. Pérez