From 90283649e277f99277c25772b380a2fccb3fcd60 Mon Sep 17 00:00:00 2001 From: Joe Fitzgerald Date: Wed, 4 Sep 2019 05:38:03 -0600 Subject: [PATCH] use built-in context, remove unused code --- passwordcredentials/passwordcredentials.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/passwordcredentials/passwordcredentials.go b/passwordcredentials/passwordcredentials.go index f76253d..33a9941 100644 --- a/passwordcredentials/passwordcredentials.go +++ b/passwordcredentials/passwordcredentials.go @@ -14,25 +14,11 @@ import ( "strings" "time" - "golang.org/x/net/context" + "context" + "golang.org/x/oauth2" ) -// tokenFromInternal maps an *internal.Token struct into -// an *oauth2.Token struct. -func tokenFromInternal(t *internalToken) *oauth2.Token { - if t == nil { - return nil - } - tk := &oauth2.Token{ - AccessToken: t.AccessToken, - TokenType: t.TokenType, - RefreshToken: t.RefreshToken, - Expiry: t.Expiry, - } - return tk.WithExtra(t.Raw) -} - func retrieveToken(ctx context.Context, ClientID, ClientSecret, TokenURL string, v url.Values) (*oauth2.Token, error) { hc := ContextClient(ctx) v.Set("client_id", ClientID) @@ -46,8 +32,8 @@ func retrieveToken(ctx context.Context, ClientID, ClientSecret, TokenURL string, if err != nil { return nil, err } - defer r.Body.Close() body, err := ioutil.ReadAll(io.LimitReader(r.Body, 1<<20)) + r.Body.Close() if err != nil { return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) }