From 32b45383ad63f4a8bcfb8c6f4b7b4651ec14fcf3 Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Sun, 31 Aug 2014 15:36:50 -0700 Subject: [PATCH] Managed VM users should depend on http.DefaultTransport by default. --- google/appengine.go | 5 +++-- google/appenginevm.go | 24 +++++++++++------------- google/google.go | 6 +++--- jwt.go | 6 +++--- oauth2.go | 6 +++--- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/google/appengine.go b/google/appengine.go index 506db23..4a99ffc 100644 --- a/google/appengine.go +++ b/google/appengine.go @@ -12,8 +12,9 @@ import ( // AppEngineConfig represents a configuration for an // App Engine application's Google service account. type AppEngineConfig struct { - // Transport represents the default transport to be used while constructing - // oauth2.Transport instances from this configuration. + // Transport is the transport to be used + // to construct new oauth2.Transport instances from + // this configuration. Transport *urlfetch.Transport context appengine.Context diff --git a/google/appenginevm.go b/google/appenginevm.go index ae466e4..ea9acc3 100644 --- a/google/appenginevm.go +++ b/google/appenginevm.go @@ -3,33 +3,31 @@ package google import ( + "net/http" + "github.com/golang/oauth2" "google.golang.org/appengine" - "google.golang.org/appengine/urlfetch" ) // AppEngineConfig represents a configuration for an // App Engine application's Google service account. type AppEngineConfig struct { - // Transport represents the default transport to be used while constructing - // oauth2.Transport instances from this configuration. - Transport *urlfetch.Transport - context appengine.Context + // Transport is the round tripper to be used + // to construct new oauth2.Transport instances from + // this configuration. + Transport http.RoundTripper - scopes []string + context appengine.Context + scopes []string } // NewAppEngineConfig creates a new AppEngineConfig for the // provided auth scopes. func NewAppEngineConfig(context appengine.Context, scopes []string) *AppEngineConfig { return &AppEngineConfig{ - Transport: &urlfetch.Transport{ - Context: context, - Deadline: 0, - AllowInvalidServerCertificate: false, - }, - context: context, - scopes: scopes, + Transport: http.DefaultTransport, + context: context, + scopes: scopes, } } diff --git a/google/google.go b/google/google.go index a9d2d95..e170415 100644 --- a/google/google.go +++ b/google/google.go @@ -37,12 +37,12 @@ type metaTokenRespBody struct { // ComputeEngineConfig represents a OAuth 2.0 consumer client // running on Google Compute Engine. type ComputeEngineConfig struct { - // Client is the default HTTP client to be used while retrieving + // Client is the HTTP client to be used to retrieve // tokens from the OAuth 2.0 provider. Client *http.Client - // Transport represents the default round tripper to be used - // while constructing new oauth2.Transport instances from + // Transport is the round tripper to be used + // to construct new oauth2.Transport instances from // this configuration. Transport http.RoundTripper diff --git a/jwt.go b/jwt.go index ba83c1b..e34ef8c 100644 --- a/jwt.go +++ b/jwt.go @@ -67,12 +67,12 @@ func NewJWTConfig(opts *JWTOptions, aud string) (*JWTConfig, error) { // JWTConfig represents an OAuth 2.0 provider and client options to // provide authorized transports with a Bearer JWT token. type JWTConfig struct { - // Client is the default HTTP client to be used while retrieving + // Client is the HTTP client to be used to retrieve // tokens from the OAuth 2.0 provider. Client *http.Client - // Transport represents the default round tripper to be used - // while constructing new oauth2.Transport instances from + // Transport is the round tripper to be used + // to construct new oauth2.Transport instances from // this configuration. Transport http.RoundTripper diff --git a/oauth2.go b/oauth2.go index 936b2d4..6441316 100644 --- a/oauth2.go +++ b/oauth2.go @@ -111,12 +111,12 @@ func NewConfig(opts *Options, authURL, tokenURL string) (*Config, error) { // Config represents the configuration of an OAuth 2.0 consumer client. type Config struct { - // Client is the default HTTP client to be used while retrieving + // Client is the HTTP client to be used to retrieve // tokens from the OAuth 2.0 provider. Client *http.Client - // Transport represents the default round tripper to be used - // while constructing new oauth2.Transport instances from + // Transport is the round tripper to be used + // to construct new oauth2.Transport instances from // this configuration. Transport http.RoundTripper