Merge branch 'cache' of github.com:rakyll/oauth2 into cache
This commit is contained in:
@@ -64,6 +64,7 @@ type TokenFetcher interface {
|
||||
// If the implementation doesn't know how to retrieve a new token,
|
||||
// it returns an error.
|
||||
FetchToken(existing *Token) (*Token, error)
|
||||
Cache() Cache
|
||||
}
|
||||
|
||||
// Options represents options to provide OAuth 2.0 client credentials
|
||||
@@ -128,6 +129,8 @@ type Config struct {
|
||||
authURL string
|
||||
// TokenURL is the URL used to retrieve OAuth tokens.
|
||||
tokenURL string
|
||||
|
||||
cache Cache
|
||||
}
|
||||
|
||||
// Options returns options.
|
||||
@@ -214,6 +217,11 @@ func (c *Config) FetchToken(existing *Token) (*Token, error) {
|
||||
return existing, err
|
||||
}
|
||||
|
||||
// Cache returns a cache if specified, otherwise nil.
|
||||
func (c *Config) Cache() Cache {
|
||||
return c.cache
|
||||
}
|
||||
|
||||
// Checks if all required configuration fields have non-zero values.
|
||||
func (c *Config) validate() error {
|
||||
if c.opts.ClientID == "" {
|
||||
|
||||
Reference in New Issue
Block a user