Documentation ¶
Index ¶
- func AsyncRefreshingTokenSource(ctx context.Context, conf AsyncRefreshingConfig, ...) (oauth2.TokenSource, error)
- func SmartAccessTokenSource(ctx context.Context, scopes ...string) (oauth2.TokenSource, error)
- func SmartIDTokenSource(ctx context.Context, audience string) (oauth2.TokenSource, error)
- type AsyncRefreshingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsyncRefreshingTokenSource ¶
func AsyncRefreshingTokenSource(ctx context.Context, conf AsyncRefreshingConfig, genFunc func(ctx context.Context) (oauth2.TokenSource, error)) (oauth2.TokenSource, error)
AsyncRefreshingTokenSource create TokenSource with the refresh config conf and the TokenSource generator function genFunc. genFunc will be called to generate the one-time TokenSource instance every time to refresh. Note: AsyncRefreshingTokenSource fetches the first token synchronously.
func SmartAccessTokenSource ¶
SmartAccessTokenSource generate oauth2.TokenSource which generates access token and supports CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT environment variable.
func SmartIDTokenSource ¶
SmartIDTokenSource generate oauth2.TokenSource which generates ID token and supports CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT environment variable.
Types ¶
type AsyncRefreshingConfig ¶
type AsyncRefreshingConfig struct { // MarginBeforeExpiry is the margin for refreshing the token before Expiry. // If it is zero value, TokenSource don't care about Expiry. MarginBeforeExpiry time.Duration // RandomizationFactorForRefreshInterval is randomization factor for MarginBeforeExpiry. RandomizationFactorForMarginBeforeExpiry float64 // RefreshInterval is interval for refreshing token if Expiry based refreshing is not applied. // If not set, 30 minutes is default interval. RefreshInterval time.Duration // RandomizationFactorForRefreshInterval is randomization factor for RefreshInterval. RandomizationFactorForRefreshInterval float64 // Backoff is backoff configuration for TokenSource.Token(). // If not set, backoff.NewExponentialBackOff is used as the default value. // See also https://pkg.go.dev/github.com/cenkalti/backoff/v4#NewExponentialBackOff. // If IsRetryable isn't set, no backoff will be performed. Backoff backoff.BackOff // IsRetryable is the predicate function for retryable errors. // Default: never retry. IsRetryable func(err error) bool }
AsyncRefreshingConfig is the refresh configuration of AsyncRefreshingTokenSource.