Provide a transport constructor for transporters with a cache.

This commit is contained in:
Burcu Dogan
2014-05-26 14:45:41 +02:00
parent 909f098dcd
commit 58513eb0ea
4 changed files with 39 additions and 45 deletions

View File

@@ -188,6 +188,15 @@ func (c *Config) NewTransportWithCode(exchangeCode string) (Transport, error) {
return NewAuthorizedTransport(c, token), nil
}
func (c *Config) NewTransportWithCache(cache Cache) (Transport, error) {
token, err := cache.Read()
if err != nil {
return nil, err
}
c.cache = cache
return NewAuthorizedTransport(c, token), nil
}
// Exchange exchanges the exchange code with the OAuth 2.0 provider
// to retrieve a new access token.
func (c *Config) Exchange(exchangeCode string) (*Token, error) {