From 6ee9c84a7bb94279279c1803307b14ff7f7d8ff6 Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Sun, 22 Jun 2014 14:46:15 -0700 Subject: [PATCH] App Engine implementations should use the cached transport. --- google/appengine.go | 12 +----------- google/appenginevm.go | 11 +---------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/google/appengine.go b/google/appengine.go index 51120a8..b995c21 100644 --- a/google/appengine.go +++ b/google/appengine.go @@ -14,7 +14,6 @@ import ( type AppEngineConfig struct { context appengine.Context scopes []string - cache oauth2.Cache } // 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 // the requests with the application's service account. func (c *AppEngineConfig) NewTransportWithCache(cache oauth2.Cache) (oauth2.Transport, error) { - token, err := cache.Read() - if err != nil { - return nil, err - } - c.cache = cache - return oauth2.NewAuthorizedTransport(c, token), nil + return oauth2.NewAuthorizedTransportWithCache(c, cache) } // 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, }, nil } - -func (c *AppEngineConfig) Cache() oauth2.Cache { - return c.cache -} diff --git a/google/appenginevm.go b/google/appenginevm.go index 1a6ff37..052b395 100644 --- a/google/appenginevm.go +++ b/google/appenginevm.go @@ -32,12 +32,7 @@ func (c *AppEngineConfig) NewTransport() oauth2.Transport { // NewTransport returns a token-caching transport that authorizes // the requests with the application's service account. func (c *AppEngineConfig) NewTransportWithCache(cache oauth2.Cache) (oauth2.Transport, error) { - token, err := cache.Read() - if err != nil { - return nil, err - } - c.cache = cache - return oauth2.NewAuthorizedTransport(c, token), nil + return oauth2.NewAuthorizedTransportWithCache(c, cache) } // 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, }, nil } - -func (c *AppEngineConfig) Cache() oauth2.Cache { - return c.cache -}