Documentation
¶
Overview ¶
Package auth is an internal package that provides authentication utilities.
IMPORTANT: This package is not meant to be used directly by consumers of the SDK and is subject to change without notice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCachedTokenSource ¶
func NewCachedTokenSource(ts oauth2.TokenSource, opts ...Option) oauth2.TokenSource
NewCachedTokenProvider wraps a oauth2.TokenSource to cache the tokens it returns. By default, the cache will refresh tokens asynchronously a few minutes before they expire.
The token cache is safe for concurrent use by multiple goroutines and will guarantee that only one token refresh is triggered at a time.
The token cache does not take care of retries in case the token source returns and error; it is the responsibility of the provided token source to handle retries appropriately.
If the TokenSource is already a cached token source (obtained by calling this function), it is returned as is.
Types ¶
type Option ¶
type Option func(*cachedTokenSource)
func WithAsyncRefresh ¶
WithAsyncRefresh enables or disables the asynchronous token refresh.
func WithCachedToken ¶
WithCachedToken sets the initial token to be used by a cached token source.