Skip to content
Snippets Groups Projects
Commit 63847a67 authored by Cresson Remi's avatar Cresson Remi
Browse files

Merge branch 'issue_21' into 'main'

Fix token renewal for expired token (issue #21)

See merge request !25
parents b33b321d b8eaddb2
No related branches found
No related tags found
1 merge request!25Fix token renewal for expired token (issue #21)
Pipeline #264812 passed with warnings
......@@ -197,6 +197,9 @@ class OAuth2Session:
log.debug("access_token_ttl is %s", access_token_ttl_seconds)
if access_token_ttl_seconds >= ttl_margin_seconds:
# Token is still valid
log.debug(
"Credentials from %s still valid", JWT_FILE
)
return
if access_token_ttl_seconds < ttl_margin_seconds:
# Access token in not valid, but refresh might be
......@@ -221,13 +224,7 @@ class OAuth2Session:
log.debug("Trying to grab credentials from %s", JWT_FILE)
try:
with open(JWT_FILE, encoding='UTF-8') as json_file:
self.jwt = self.grant.refresh_token(
JWT(**json.load(json_file))
)
if self.jwt:
log.debug(
"Credentials from %s still valid", JWT_FILE
)
self.jwt = JWT(**json.load(json_file))
except FileNotFoundError as error:
log.warning(
"Warning: can't use token from file %s (%s)",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment