add expires_at check to gigachat authenticator

This commit is contained in:
KnyazSh 2026-06-22 18:46:48 +00:00
parent 0cc9147f49
commit 4fc3e2e064

View file

@ -112,12 +112,13 @@ def get_access_token(
# Request new token
token, expires_at = _request_token_sync(credentials, scope, auth_url)
# Cache token
ttl_seconds = max(
0, (expires_at - TOKEN_EXPIRY_BUFFER_MS - time.time() * 1000) / 1000
)
if ttl_seconds > 0:
_token_cache.set_cache(cache_key, (token, expires_at), ttl=ttl_seconds)
if expires_at:
# Cache token
ttl_seconds = max(
0, (expires_at - TOKEN_EXPIRY_BUFFER_MS - time.time() * 1000) / 1000
)
if ttl_seconds > 0:
_token_cache.set_cache(cache_key, (token, expires_at), ttl=ttl_seconds)
return token