diff --git a/main.py b/main.py index 252ee71..e17a6f4 100644 --- a/main.py +++ b/main.py @@ -156,6 +156,19 @@ def get_access_token(): else: token = token_info["access_token"] +def is_token_expired(): + sp_oauth = spotipy.SpotifyOAuth( + client_id, + client_secret, + redirect_uri, + scope=scope, + #cache_path=cache_path, + username=username, + open_browser=False + ) + token_info = sp_oauth.get_cached_token() + return token_info.is_token_expired() + if __name__ == "__main__": main() @@ -164,6 +177,8 @@ if __name__ == "__main__": while True: drawCanvas() time.sleep(10) + if(is_token_expired()): + get_access_token()