From a7a8d7a4102b0b7c1b83791947ccb662f060eca7 Mon Sep 17 00:00:00 2001 From: Carl Lundin <108372512+clundin25@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:52:25 -0800 Subject: [PATCH] feat: Modify the refresh window to match go/async-token-refresh. Serverless tokens are cached until 4 minutes before expiration, so 4 minutes is the ideal refresh window. (#1352) * feat: Modify the refresh window to match go/async-token-refresh. Serverless tokens are cached until 4 minutes before expiration, so 4 minutes is the ideal refresh window. * Tweak time to 3 minutes and 45 seconds, giving the MDS a 15 second window to refresh. * Update both expiration margin and refresh margin. --- .../java/com/google/auth/oauth2/OAuth2Credentials.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java b/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java index 94ddeb549..20e1c92e5 100644 --- a/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/OAuth2Credentials.java @@ -68,8 +68,8 @@ public class OAuth2Credentials extends Credentials { private static final long serialVersionUID = 4556936364828217687L; - static final Duration DEFAULT_EXPIRATION_MARGIN = Duration.ofMinutes(5); - static final Duration DEFAULT_REFRESH_MARGIN = Duration.ofMinutes(6); + static final Duration DEFAULT_EXPIRATION_MARGIN = Duration.ofMinutes(3); + static final Duration DEFAULT_REFRESH_MARGIN = Duration.ofMinutes(3).plusSeconds(45); private static final ImmutableMap> EMPTY_EXTRA_HEADERS = ImmutableMap.of(); @VisibleForTesting private final Duration expirationMargin;