From 8df70c790e03a6b58a02c450122c61bc43478b5d Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Wed, 5 Feb 2025 10:55:51 +0100 Subject: pkg/auth: retry https://oauth2.googleapis.com/tokeninfo call 3 times --- pkg/auth/auth.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'pkg/auth') diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index 8b72c24f5..78d1dbeef 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -73,9 +73,16 @@ type jwtClaims struct { } func (auth *Endpoint) queryTokenInfo(tokenValue string) (*jwtClaims, error) { - resp, err := http.PostForm(auth.url, url.Values{"id_token": {tokenValue}}) + var resp *http.Response + var err error + for i := 0; i < 3; i++ { + resp, err = http.PostForm(auth.url, url.Values{"id_token": {tokenValue}}) + if err == nil { + break + } + } if err != nil { - return nil, fmt.Errorf("http.PostForm: %w", err) + return nil, fmt.Errorf("http.PostForm failed 3 times: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { -- cgit mrf-deployment