Ich habe eine app in Django gebaut, die Spotipy, ein Spotify-API Python-Bibliothek, und verwendet den Befehl spotipy.util.prompt_for_user_token()
als solche verwendet ein Token und Zugriff auf meine private Bibliothek als solche zu generieren:Was mache ich mit einem spotify API-Authentifizierungsumleitungs-URI in Django?
import spotipy
import spotipy.util as util
import os, ast
#Spotify API keys
scope = "playlist-read-private"
uir = "http://localhost:8000"
username = "<MY_USERNAME>"
spotify_uid = os.environ["SPOTIFY_UID"]
spotify_usec = os.environ["SPOTIFY_USEC"]
print "retrieved keys from OS"
#set up access
def get_access():
try:
token = util.prompt_for_user_token(username, scope, spotify_uid, spotify_usec, uir)
print "SUCCESS"
return spotipy.Spotify(auth=token)
except:
print "FAILED TO LOAD"
Ich mag würde Die App hat einen Login anstelle eines hardcoded Login, aber ich kann nicht herausfinden, wie.
Im Moment habe ich eine 'Login' Taste, die versucht, die Login-Seite Umleitung über Javascript, durch den Aufruf der oben genannten Code mit einem Benutzernamen Parameter, aber das öffnet eine neue Seite und das folgende ist in der Konsole:
User authentication requires interaction with your
web browser. Once you enter your credentials and
give authorization, you will be redirected to
a url. Paste that url you were directed to to
complete the authorization.
Opening https://accounts.spotify.com/authorize?scope=playlist-read- private&redirect_uri=http%3A%2F%2Flocalhost%3A8000&response_type=code&client_id=<CLIENT_ID> in your browser
Enter the URL you were redirected to: [30/Jun/2016 15:53:54] "GET /?code=<TOKEN>HTTP/1.1" 200 2881
Anmerkung:der Text in Klammern Karat ersetzt wurden, da sie private Schlüssel waren.
Ich möchte es auf eine ähnliche Funktionalität haben, wie diese Website-Logins Griffe: http://static.echonest.com/SortYourMusic/
Haben Sie eine Lösung dafür gefunden? – Caaarlos