Use the oauth2 context ability to specify a clean http client. (#2808)

Hopefully fixes #2793
This commit is contained in:
Jeff Mitchell
2017-06-05 12:27:01 -04:00
committed by GitHub
parent 186e7dd1f4
commit a2a0b44d79
2 changed files with 11 additions and 10 deletions

View File

@@ -1,6 +1,8 @@
package github
import (
"context"
"github.com/google/go-github/github"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/vault/logical"
@@ -63,7 +65,8 @@ type backend struct {
func (b *backend) Client(token string) (*github.Client, error) {
tc := cleanhttp.DefaultClient()
if token != "" {
tc = oauth2.NewClient(oauth2.NoContext, &tokenSource{Value: token})
ctx := context.WithValue(context.Background(), oauth2.HTTPClient, tc)
tc = oauth2.NewClient(ctx, &tokenSource{Value: token})
}
return github.NewClient(tc), nil