Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToOAuthConfig ¶
func ToOAuthConfig(tc TokenCache) (oauth2.Config, error)
ToOAuthConfig constructs an OAuth2.0 config with the stored login endpoint and client info.
Types ¶
type OAuth2Token ¶
type OAuth2Token interface { Token() *oauth2.Token ExpiresIn() (int, bool) RefreshExpiresIn() (int, bool) }
func WrapOAuth2Token ¶
func WrapOAuth2Token(ot *oauth2.Token) OAuth2Token
type PathFromFlags ¶
type PathFromFlags interface { // CachePath returns either the configured cache path or Default() if it // hasn't been set. CachePath() string // Default returns some default that should be used if the path isn't set. Default() string }
PathFromFlags allow passing an accessor to a cache path around that hasn't been resolved yet and may be set by command line flags.
func NewPathFromFlags ¶
func NewPathFromFlags(pfix string, flagSet tbnflag.FlagSet) PathFromFlags
NewPathFromFlags updates flagSet with the flags necessary to configure a TokenCache file path and constructs a default file with the specified pfix.
func NewStaticPath ¶
func NewStaticPath(p string) PathFromFlags
NewStaticPath returns a PathFromFlags that always returns the path p.
type TokenCache ¶
type TokenCache struct { ClientID string ClientKey string ProviderURL string Username string ExpiresAt *time.Time RefreshExpiresAt *time.Time Token *oauth2.Token // contains filtered or unexported fields }
TokenCache stores cached data about a login endpoint and an auth token previously retrieved through user/pass authentication. It is sufficient to take subsequent actions without needing to reauthenticate with the Turbine Labs API.
func NewFromFile ¶
func NewFromFile(path string) (TokenCache, error)
NewFromFile constructs a new TokenCache populated with information that was saved in the file at path.
func (TokenCache) Expired ¶
func (tc TokenCache) Expired() bool
Expired checks the expiration time of the access token and the refresh token to see if the cached auth info can be used or if the user will need to login again.
func (TokenCache) Save ¶
func (tc TokenCache) Save(path string) error
Save attempts to write the TokenCache information to a file at path. If the file does not exist it will be created with 0600 file permissions (user only read/write).
func (*TokenCache) SetToken ¶
func (tc *TokenCache) SetToken(tkn OAuth2Token)
SetToken processes an auth token from the Turbine Labs API and extracts expiration information saving all this into the TokenCache struct.