Skip to content

Commit

Permalink
feat: Modify the token refresh window
Browse files Browse the repository at this point in the history
Set the token refresh window from 30s to 3 minutes and 45 seconds.
  • Loading branch information
clundin25 committed Nov 15, 2023
1 parent df1f39f commit 27f7c1c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions google/auth/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@

from google.auth import exceptions

# Token server doesn't provide a new a token when doing refresh unless the
# token is expiring within 30 seconds, so refresh threshold should not be
# more than 30 seconds. Otherwise auth lib will send tons of refresh requests
# until 30 seconds before the expiration, and cause a spike of CPU usage.
REFRESH_THRESHOLD = datetime.timedelta(seconds=20)
# The smallest MDS cache used by this library stores tokens until 4 minutes from
# expiry.
REFRESH_THRESHOLD = datetime.timedelta(minutes=3, seconds=45)


def copy_docstring(source_class):
Expand Down

0 comments on commit 27f7c1c

Please sign in to comment.