From 9e335902bb01a2f8635e52d29c56eec621162eab Mon Sep 17 00:00:00 2001 From: Lukas Schulz Date: Sun, 20 Dec 2020 02:21:46 +0100 Subject: [PATCH] yes. --- main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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()