From b235b1f8c718be6b8f361074d371768617a3da3a Mon Sep 17 00:00:00 2001 From: Eytan Kidron Date: Tue, 18 Oct 2022 11:38:24 -0400 Subject: [PATCH] fix(idtoken): Allow missing age in http response header (#1715) Per https://togithub.com/googleapis/google-api-go-client/issues/1711 allow the "age" field to be missing from the http response header file and treat it as a zero if it is missing. --- idtoken/cache.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/idtoken/cache.go b/idtoken/cache.go index 392181f2210..ed57d55f650 100644 --- a/idtoken/cache.go +++ b/idtoken/cache.go @@ -111,7 +111,11 @@ func (c *cachingClient) calculateExpireTime(headers http.Header) time.Time { maxAge = ma } } - age, err := strconv.Atoi(headers.Get("age")) + a := headers.Get("age") + if a == "" { + return c.now().Add(time.Duration(maxAge) * time.Second) + } + age, err := strconv.Atoi(a) if err != nil { return c.now() }