forked from remote/oauth2
Provide a transport constructor for transporters with a cache.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user