Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenProvider ¶
AccessTokenProvider provides a method to get the bearer token for use when authorizing to a 3rd-party provider API.
type RotatedAccessTokenProvider ¶
type RotatedAccessTokenProvider struct {
// contains filtered or unexported fields
}
RotatedAccessTokenProvider is an implementation of AccessTokenProvider that uses OAuth2 refresh token flow to renew the acess token. The credentials are stored in the given persistent store.
To have an up-to-date token, one must run RefreshLoop() in a background goroutine.
func NewRotatedTokenProvider ¶
func NewRotatedTokenProvider(ctx context.Context, cfg RotatedAccessTokenProviderConfig) (*RotatedAccessTokenProvider, error)
NewRotatedTokenProvider creates a new RotatedAccessTokenProvider from the given config. NewRotatedTokenProvider will return an error if the store does not have existing credentials, meaning they need to be acquired first (e.g. via OAuth2 authorization code flow).
func (*RotatedAccessTokenProvider) GetAccessToken ¶
func (r *RotatedAccessTokenProvider) GetAccessToken() (string, error)
GetAccessToken implements AccessTokenProvider()
func (*RotatedAccessTokenProvider) RefreshLoop ¶
func (r *RotatedAccessTokenProvider) RefreshLoop(ctx context.Context)
RefreshLoop runs the credential refresh process.
type RotatedAccessTokenProviderConfig ¶
type RotatedAccessTokenProviderConfig struct { RetryInterval time.Duration TokenBufferInterval time.Duration Store storage.Store Refresher oauth.Refresher Clock clockwork.Clock Log *logrus.Entry }
RotatedAccessTokenProviderConfig contains parameters and dependencies for RotatedAccessTokenProvider
func (*RotatedAccessTokenProviderConfig) CheckAndSetDefaults ¶
func (c *RotatedAccessTokenProviderConfig) CheckAndSetDefaults() error
CheckAndSetDefaults validates a configuration and sets default values
type StaticAccessTokenProvider ¶
type StaticAccessTokenProvider struct {
// contains filtered or unexported fields
}
StaticAccessTokenProvider is an implementation of AccessTokenProvider that always returns the specified token.
func NewStaticAccessTokenProvider ¶
func NewStaticAccessTokenProvider(token string) *StaticAccessTokenProvider
NewStaticAccessTokenProvider creates a new StaticAccessTokenProvider.
func (*StaticAccessTokenProvider) GetAccessToken ¶
func (s *StaticAccessTokenProvider) GetAccessToken() (string, error)
GetAccessToken implements AccessTokenProvider