Use default client rather than a new client instance.

This commit is contained in:
Burcu Dogan 2014-07-14 10:26:21 -07:00
parent 648dd50ab3
commit 6b4f2ed2ce
3 changed files with 3 additions and 4 deletions

View File

@ -76,7 +76,7 @@ func (c *ComputeEngineConfig) FetchToken(existing *oauth2.Token) (token *oauth2.
return return
} }
req.Header.Add("X-Google-Metadata-Request", "True") req.Header.Add("X-Google-Metadata-Request", "True")
resp, err := (&http.Client{}).Do(req) resp, err := http.DefaultClient.Do(req)
if err != nil { if err != nil {
return return
} }

3
jwt.go
View File

@ -100,8 +100,7 @@ func (c *JWTConfig) FetchToken(existing *Token) (token *Token, err error) {
v.Set("assertion", payload) v.Set("assertion", payload)
// Make a request with assertion to get a new token. // Make a request with assertion to get a new token.
client := http.Client{} resp, err := http.DefaultClient.PostForm(c.aud, v)
resp, err := client.PostForm(c.aud, v)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -206,7 +206,7 @@ func (c *Config) exchange(exchangeCode string) (*Token, error) {
func (c *Config) updateToken(tok *Token, v url.Values) error { func (c *Config) updateToken(tok *Token, v url.Values) error {
v.Set("client_id", c.opts.ClientID) v.Set("client_id", c.opts.ClientID)
v.Set("client_secret", c.opts.ClientSecret) v.Set("client_secret", c.opts.ClientSecret)
r, err := (&http.Client{}).PostForm(c.tokenURL, v) r, err := http.DefaultClient.PostForm(c.tokenURL, v)
if err != nil { if err != nil {
return err return err
} }