summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/oauth2/token.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-07-16 08:13:03 +0800
committertechknowlogick <techknowlogick@gitea.io>2019-07-15 20:13:03 -0400
commitd2958d9f4633ddbde2202952d665b3d562eb0415 (patch)
tree59f6d1c0ed6c886ba0caa6d96d5a175debf376b7 /vendor/golang.org/x/oauth2/token.go
parent760c47389696e97131a3d13629a0a5a4576e5283 (diff)
downloadgitea-d2958d9f4633ddbde2202952d665b3d562eb0415.tar.gz
gitea-d2958d9f4633ddbde2202952d665b3d562eb0415.zip
Move status table to cron package (#7370)
Diffstat (limited to 'vendor/golang.org/x/oauth2/token.go')
-rw-r--r--vendor/golang.org/x/oauth2/token.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/vendor/golang.org/x/oauth2/token.go b/vendor/golang.org/x/oauth2/token.go
index 9be1ae5373..822720341a 100644
--- a/vendor/golang.org/x/oauth2/token.go
+++ b/vendor/golang.org/x/oauth2/token.go
@@ -118,13 +118,16 @@ func (t *Token) Extra(key string) interface{} {
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 @@ func tokenFromInternal(t *internal.Token) *Token {
// 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)