This is the error code https://api.spotify.com/v1/me/top/tracks?time_range=short_term&limit=10&offset=0:
None, reason: None
This is the code where the issue comes from:
@app.route('/top-songs')
def top_songs():
token_info = get_token()
if not token_info:
return "Not work"
print("Access Token:", token_info['access_token'])
access_token = token_info['access_token']
sp = spotipy.Spotify(auth=access_token)
try:
top_tracks = sp.current_user_top_tracks(limit=10, offset=0, time_range='short_term')['items']
except spotipy.SpotifyException as e:
print("Spotify API Error:", e)
# Extract relevant information from top_tracks
# Example: track_names = [track['name'] for track in top_tracks['items']]
return render_template('index.html')
I am trying to print the top songs from the Spotify API and display it on a HTML file. The error seems to be coming up at the line:
top_tracks = sp.current_user_top_tracks(limit=10, offset=0, time_range='short_term')['items']
because I don't get the error if that is removed. Anyone have any idea?
from Getting a no access token error on the Spotify API using it flask
No comments:
Post a Comment