Documentation
¶
Overview ¶
Package token provides utilities for retrieving and refreshing client_credentials tokens using an oauth.Client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider = httpclient.TokenProvider
Provider accepts a context and returns either:
(1) a nonempty token and a nil error, or
(2) an empty string and a non-nil error.
func CreateAndStartRefreshingOAuthProvider ¶
func CreateAndStartRefreshingOAuthProvider(ctx context.Context, client oauth.ClientCredentialClient, clientID, clientSecret string, refreshInterval time.Duration) Provider
CreateAndStartRefreshingOAuthProvider returns a Provider which caches and periodically refreshes a client token. When it returns, we have not yet necessarily successfully fetched a valid token.
func NewRetryingTokenProvider ¶
NewRetryingTokenProvider takes a TokenProvider and uses it to create another TokenProvider that retries forever.
type Refresher ¶
type Refresher struct {
// contains filtered or unexported fields
}
Refresher periodically updates its token via its Provider. This type provides thread-safe access to an up-to-date token.
func NewRefresher ¶
NewRefresher constructs a Refresher from a Provider and a token's TTL.
func (*Refresher) Run ¶
Run starts an endless refresh loop and is a blocking call; this will return once the context is cancelled.
func (*Refresher) Token ¶
Token returns the currently stored token or an error if (1) there is no token stored and an attempt to get the token has failed, or (2) the stored token is not usable. This method will block until an attempt is completed to the provider to get the token (either success or fail).