summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/oauth2/google/error.go
diff options
context:
space:
mode:
authorNicolas Paul <n@nc0.fr>2023-04-16 20:09:08 +0200
committerNicolas Paul <n@nc0.fr>2023-04-16 20:09:08 +0200
commitefc9e73404efc108c69b4498acb312d760cf8e5d (patch)
treea6522428a9b92ff52ff4d590b23067b22e4960d5 /vendor/golang.org/x/oauth2/google/error.go
parent1f9284de04ae5c996e4218918822297280ede164 (diff)
Go mod tidy
Diffstat (limited to 'vendor/golang.org/x/oauth2/google/error.go')
-rw-r--r--vendor/golang.org/x/oauth2/google/error.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/vendor/golang.org/x/oauth2/google/error.go b/vendor/golang.org/x/oauth2/google/error.go
deleted file mode 100644
index d84dd00..0000000
--- a/vendor/golang.org/x/oauth2/google/error.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package google
-
-import (
- "errors"
-
- "golang.org/x/oauth2"
-)
-
-// AuthenticationError indicates there was an error in the authentication flow.
-//
-// Use (*AuthenticationError).Temporary to check if the error can be retried.
-type AuthenticationError struct {
- err *oauth2.RetrieveError
-}
-
-func newAuthenticationError(err error) error {
- re := &oauth2.RetrieveError{}
- if !errors.As(err, &re) {
- return err
- }
- return &AuthenticationError{
- err: re,
- }
-}
-
-// Temporary indicates that the network error has one of the following status codes and may be retried: 500, 503, 408, or 429.
-func (e *AuthenticationError) Temporary() bool {
- if e.err.Response == nil {
- return false
- }
- sc := e.err.Response.StatusCode
- return sc == 500 || sc == 503 || sc == 408 || sc == 429
-}
-
-func (e *AuthenticationError) Error() string {
- return e.err.Error()
-}
-
-func (e *AuthenticationError) Unwrap() error {
- return e.err
-}
-
-type errWrappingTokenSource struct {
- src oauth2.TokenSource
-}
-
-func newErrWrappingTokenSource(ts oauth2.TokenSource) oauth2.TokenSource {
- return &errWrappingTokenSource{src: ts}
-}
-
-// Token returns the current token if it's still valid, else will
-// refresh the current token (using r.Context for HTTP client
-// information) and return the new one.
-func (s *errWrappingTokenSource) Token() (*oauth2.Token, error) {
- t, err := s.src.Token()
- if err != nil {
- return nil, newAuthenticationError(err)
- }
- return t, nil
-}