From c6af1d692b43833baca978948376739547cf685a Mon Sep 17 00:00:00 2001 From: Carl Lundin <108372512+clundin25@users.noreply.github.com> Date: Tue, 14 Nov 2023 20:00:07 -0800 Subject: [PATCH] feat: Modify the token refresh window (#1419) Set the token refresh window from 30s to 3 minutes and 45 seconds. --- google/auth/_helpers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/google/auth/_helpers.py b/google/auth/_helpers.py index e7e5d97cf..a6c07f7d8 100644 --- a/google/auth/_helpers.py +++ b/google/auth/_helpers.py @@ -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):