App Engine implementations should use the cached transport.

This commit is contained in:
Burcu Dogan 2014-06-22 14:46:15 -07:00
parent ea046b80de
commit 6ee9c84a7b
2 changed files with 2 additions and 21 deletions

View File

@ -14,7 +14,6 @@ import (
type AppEngineConfig struct { type AppEngineConfig struct {
context appengine.Context context appengine.Context
scopes []string scopes []string
cache oauth2.Cache
} }
// NewAppEngineConfig creates a new AppEngineConfig for the // NewAppEngineConfig creates a new AppEngineConfig for the
@ -32,12 +31,7 @@ func (c *AppEngineConfig) NewTransport() oauth2.Transport {
// NewTransport returns a token-caching transport that authorizes // NewTransport returns a token-caching transport that authorizes
// the requests with the application's service account. // the requests with the application's service account.
func (c *AppEngineConfig) NewTransportWithCache(cache oauth2.Cache) (oauth2.Transport, error) { func (c *AppEngineConfig) NewTransportWithCache(cache oauth2.Cache) (oauth2.Transport, error) {
token, err := cache.Read() return oauth2.NewAuthorizedTransportWithCache(c, cache)
if err != nil {
return nil, err
}
c.cache = cache
return oauth2.NewAuthorizedTransport(c, token), nil
} }
// FetchToken fetches a new access token for the provided scopes. // FetchToken fetches a new access token for the provided scopes.
@ -51,7 +45,3 @@ func (c *AppEngineConfig) FetchToken(existing *oauth2.Token) (*oauth2.Token, err
Expiry: expiry, Expiry: expiry,
}, nil }, nil
} }
func (c *AppEngineConfig) Cache() oauth2.Cache {
return c.cache
}

View File

@ -32,12 +32,7 @@ func (c *AppEngineConfig) NewTransport() oauth2.Transport {
// NewTransport returns a token-caching transport that authorizes // NewTransport returns a token-caching transport that authorizes
// the requests with the application's service account. // the requests with the application's service account.
func (c *AppEngineConfig) NewTransportWithCache(cache oauth2.Cache) (oauth2.Transport, error) { func (c *AppEngineConfig) NewTransportWithCache(cache oauth2.Cache) (oauth2.Transport, error) {
token, err := cache.Read() return oauth2.NewAuthorizedTransportWithCache(c, cache)
if err != nil {
return nil, err
}
c.cache = cache
return oauth2.NewAuthorizedTransport(c, token), nil
} }
// FetchToken fetches a new access token for the provided scopes. // FetchToken fetches a new access token for the provided scopes.
@ -51,7 +46,3 @@ func (c *AppEngineConfig) FetchToken(existing *oauth2.Token) (*oauth2.Token, err
Expiry: expiry, Expiry: expiry,
}, nil }, nil
} }
func (c *AppEngineConfig) Cache() oauth2.Cache {
return c.cache
}