Export Transport to allow default transport to be configurable.

This commit is contained in:
Burcu Dogan 2014-07-14 10:59:30 -07:00
parent 6b4f2ed2ce
commit 7935ece62b
1 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,9 @@ import (
// AppEngineConfig represents a configuration for an // AppEngineConfig represents a configuration for an
// App Engine application's Google service account. // App Engine application's Google service account.
type AppEngineConfig struct { type AppEngineConfig struct {
// Default transport to be used while constructing
// oauth2.Transport instances from this configuration.
Transport *urlfetch.Transport
context appengine.Context context appengine.Context
scopes []string scopes []string
} }
@ -27,6 +30,9 @@ func NewAppEngineConfig(context appengine.Context, scopes []string) *AppEngineCo
// NewTransport returns a transport that authorizes // NewTransport returns a transport that authorizes
// the requests with the application's service account. // the requests with the application's service account.
func (c *AppEngineConfig) NewTransport() oauth2.Transport { func (c *AppEngineConfig) NewTransport() oauth2.Transport {
if c.Transport != nil {
return oauth2.NewAuthorizedTransport(c.Transport, c, nil)
}
transport := &urlfetch.Transport{ transport := &urlfetch.Transport{
Context: c.context, Context: c.context,
Deadline: 0, Deadline: 0,