-
Notifications
You must be signed in to change notification settings - Fork 971
Open
Labels
Description
Describe the bug
is_token_expired()
uses time.time()
which returns system local time, which, when running on a non-UTC system, can return incorrectly.
Your code
token_info = auth_manager.cache_handler.get_cached_token()
print(f"Token expires_at: {token_info['expires_at']}")
print(f"Local Time (Pacific): {int(time.time())}")
print(f"UTC Time: {int(time.mktime(time.gmtime()))}")
# Token shows not expired, but it is expected that it is expired
print(auth_manager.is_token_expired(token_info))
Token expires_at: 1669239147
Local Time (Pacific): 1669229727
UTC Time: 1669247727
False
Expected behavior
Replace time.time()
with, e.g., time.mktime(time.gmtime())
wherever used.
Environment:
- OS: Mac
- Python version: 3.6.8
- spotipy version: 2.21.0
- IDE: VSCode
Additional context
Add any other context about the problem here.
stephanebruckert and iamdavehawkins