Issue
I am creating a Spotify app using Flask and encountering an issue with getting the end users data. Mine shows up instead of theirs. Their documentation has not helped, and other solutions on here haven't worked for me.
Here is my Flask code:
@app.route('/authenticate')
def authentication():
sp_oauth = create_spotify_oauth()
auth_url = sp_oauth.get_authorize_url()
return redirect(auth_url)
@app.route('/redirectPage')
def redirectPage():
sp_oauth = create_spotify_oauth()
code = request.args.get('code')
token_info = sp_oauth.get_access_token(code)
session[TOKEN_INFO] = token_info
return redirect(url_for('playlist_or_album'))
and my spotify oauth function:
def create_spotify_oauth():
return SpotifyOAuth(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
redirect_uri=url_for('redirectPage', _external=True),
scope='playlist-modify-public'
)
I have searched error logs and other methods for authorization. This one suits my needs and I'd prefer to not change. There are no errors, I just cannot trace why it would be logging in me instead of other user.
Solution
Tim Roberts comment is right- you need to use the end users credentials- but I actually ran into the same problem after doing that. Make sure to clear Spotify's cache file if you encounter this issue after user proper credentials:
def cleanup():
cache_file = '.cache'
if os.path.exists(cache_file):
os.remove(cache_file)
Answered By - thetaco
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.