Merge branch 'cache' of github.com:rakyll/oauth2 into cache

This commit is contained in:
Burcu Dogan
2014-05-21 15:24:41 +02:00
4 changed files with 83 additions and 0 deletions

View File

@@ -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 == "" {