What mache ich eine mit Spotify api Authentifizierung Redirect uri in Django?

Ich habe in Django eine App erstellt, die Spotipy, eine Spotify-API-Python-Bibliothek, und das @ verwendespotipy.util.prompt_for_user_token() Befehl als solcher, um ein Token zu generieren und auf meine private Bibliothek als solche zuzugreifen:

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 möchte, dass die App ein UI-Login anstelle eines fest codierten Logins hat, aber ich kann nicht herausfinden, wie.

Im Moment habe ich eine Anmeldeschaltfläche, die versucht, die Umleitung der Anmeldeseite über Javascript auszulösen, indem sie den obigen Code mit einem Benutzernamen-Parameter aufruft. Dadurch wird jedoch eine neue Seite geöffnet, und in der Konsole wird Folgendes angezeigt:

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 

Hinweis Der Text in Karat-Klammern wurde ersetzt, da es sich um private Schlüssel handelte.

Ich möchte, dass es ähnliche Funktionen wie diese Website für Anmeldungen bietet:http: //static.echonest.com/SortYourMusic

Antworten auf die Frage(2)

Ihre Antwort auf die Frage