Documentation
¶
Overview ¶
Package tokens provides an implementation to fetch and manage OAuth2 tokens.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrCacheSetupFailed = errors.New("cache setup failed") ErrCacheFailure = errors.New("cache failure") )
Err* are sentinel errors for this package.
Functions ¶
func NewReuseTokenSource ¶
func NewReuseTokenSource(cfg *oauth2.Config) func(context.Context, *oauth2.Token) oauth2.TokenSource
NewReuseTokenSource is the anticipated default token source for the caching source to wrap.
Types ¶
type CachingSource ¶
type CachingSource struct {
// contains filtered or unexported fields
}
CachingSource is an implementation of TokenSource that will attempt to read the token from a cache. If it finds a valid token in the case, it'll use it. If not, it'll use the supplied "seed function" to fetch a new token.
func NewCachingSource ¶
func NewCachingSource( ctx context.Context, tsf func(context.Context, *oauth2.Token) oauth2.TokenSource, sf seeds.Seed, str storage.Storage, ) (*CachingSource, error)
NewCachingSource allows creating a oauth2.TokenSource that caches the results in a storage layer (provided when the thing is constructed). Allows seeding the token source with a new token if there is nothing in the cache, or if what is in the cache is invalid (e.g. the user has never signed in before).
Directories
¶
Path | Synopsis |
---|---|
Package seeds provides a way to "seed" a token source; especially one that relies on caching.
|
Package seeds provides a way to "seed" a token source; especially one that relies on caching. |
Package storage provides storage for the cachable token interface.
|
Package storage provides storage for the cachable token interface. |