'Lib Spotipy no responde

i'm trying to use the lib Spotipy for Spotify. When i execute the code below, nothing happen. I have a springboot app who receives the token generated, when i try to check him in the console's spotify he saids that the token was expired. I have all my variables set correctly, also generated secret, user and etc.

from dotenv import load_dotenv
import spotipy
import spotipy.util as util
import os
load_dotenv()


scope = "user-read-currently-playing"


token = util.prompt_for_user_token(username=os.environ.get("SPOTIPY_USERNAME"),scope=scope,client_id=os.environ.get("SPOTIPY_CLIENT_ID"), client_secret=os.environ.get("SPOTIPY_CLIENT_SECRET"),redirect_uri=os.environ.get("SPOTIPY_REDIRECT_URI"))

cache_token = token.get_access_token()

sp = spotipy.Spotify(auth=token)
currentsong = sp.currently_playing()

print(currentsong)

sorry i'm newbie to python and that is my first question here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source