This commit is contained in:
Lukas Schulz 2020-12-20 14:13:02 +01:00
parent 951ce1ccb2
commit 3a8e65f5e1

19
main.py
View file

@ -221,29 +221,12 @@ def get_access_token():
code = sp_oauth.get_auth_response() code = sp_oauth.get_auth_response()
token = sp_oauth.get_access_token(code, as_dict=False) token = sp_oauth.get_access_token(code, as_dict=False)
else: else:
if is_token_expired(): if sp_oauth.is_token_expired(token_info):
token_info = refresh_access_token(token_info) token_info = refresh_access_token(token_info)
token = token_info["access_token"] 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()
if not token_info:
return True
else:
return sp_oauth.is_token_expired(token_info)
if __name__ == "__main__": if __name__ == "__main__":
get_access_token()
main() main()
print('led-matrix-viewer started') print('led-matrix-viewer started')