I am trying to use spotipy to execute a search request from Spotify. I specified the client id, secret id and redirect url (http://127.0.0.1:8000/callback/q) in my bash_profiles, as described in the API.
def search(username, query):
token = util.prompt_for_user_token(username, scope) #like oauth with redirect url
print("received token response")
if token:
sp = spotipy.Spotify(auth=token)
return sp.search(query, 1, 0, type='track')
The problem is I am using django, which also forces me to specify the redirect url in my urls.py and a corresponding view in views.py
[from urls.py...]
url(r'^callback/q$', views.callback, name='callback'),
[from views.py...]
def callback(request):
print("callback view reached")
return render(request, 'rec/search.html')
It seems like django then intercepts displays the view from the redirect-url, so my search method never finishes executing. I am a little confused on how I get a token that requires a redirect url, yet then continue executing the rest of the method that follows the authorization request