Skip to content

Commit

Permalink
fix: race-condition on token request close to expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip1x9 committed Aug 27, 2024
1 parent 6b8a58d commit 9902e2b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fds/sdk/utils/authentication/confidential.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _is_cached_token_valid(self) -> bool:
if not self._cached_token:
log.debug("Access Token cache is empty")
return False
if time.time() < self._cached_token[CONSTS.TOKEN_EXPIRES_AT] - 30:
if time.time() < self._cached_token[CONSTS.TOKEN_EXPIRES_AT] - CONSTS.TOKEN_EXPIRY_OFFSET_SECS:
return True
else:
log.debug("Cached access token has expired at %s", self._cached_token[CONSTS.TOKEN_EXPIRES_AT])
Expand Down
1 change: 1 addition & 0 deletions src/fds/sdk/utils/authentication/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CONSTS:
# access token
TOKEN_ACCESS_TOKEN = "access_token"
TOKEN_EXPIRES_AT = "expires_at"
TOKEN_EXPIRY_OFFSET_SECS = 30

# config
CONFIG_CLIENT_ID = "clientId"
Expand Down

0 comments on commit 9902e2b

Please sign in to comment.