--- a/vendor/golang.org/x/oauth2/token.go Wed Sep 18 19:17:42 2019 +0200
+++ b/vendor/golang.org/x/oauth2/token.go Sun Feb 16 18:54:01 2020 +0100
@@ -5,6 +5,7 @@
package oauth2
import (
+ "context"
"fmt"
"net/http"
"net/url"
@@ -12,7 +13,6 @@
"strings"
"time"
- "golang.org/x/net/context"
"golang.org/x/oauth2/internal"
)
@@ -118,13 +118,16 @@
return v
}
+// timeNow is time.Now but pulled out as a variable for tests.
+var timeNow = time.Now
+
// expired reports whether the token is expired.
// t must be non-nil.
func (t *Token) expired() bool {
if t.Expiry.IsZero() {
return false
}
- return t.Expiry.Round(0).Add(-expiryDelta).Before(time.Now())
+ return t.Expiry.Round(0).Add(-expiryDelta).Before(timeNow())
}
// Valid reports whether t is non-nil, has an AccessToken, and is not expired.
@@ -151,7 +154,7 @@
// This token is then mapped from *internal.Token into an *oauth2.Token which is returned along
// with an error..
func retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) {
- tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v)
+ tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v, internal.AuthStyle(c.Endpoint.AuthStyle))
if err != nil {
if rErr, ok := err.(*internal.RetrieveError); ok {
return nil, (*RetrieveError)(rErr)