"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/golang.org/x/oauth2/token.go" between
gitea-1.9.3.tar.gz and gitea-1.9.4.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

token.go  (gitea-1.9.3):token.go  (gitea-1.9.4)
skipping to change at line 121 skipping to change at line 121
} }
case 1: // Contains a single "."; try to parse as float case 1: // Contains a single "."; try to parse as float
if f, err := strconv.ParseFloat(s, 64); err == nil { if f, err := strconv.ParseFloat(s, 64); err == nil {
return f return f
} }
} }
return v 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. // expired reports whether the token is expired.
// t must be non-nil. // t must be non-nil.
func (t *Token) expired() bool { func (t *Token) expired() bool {
if t.Expiry.IsZero() { if t.Expiry.IsZero() {
return false 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. // Valid reports whether t is non-nil, has an AccessToken, and is not expired.
func (t *Token) Valid() bool { func (t *Token) Valid() bool {
return t != nil && t.AccessToken != "" && !t.expired() return t != nil && t.AccessToken != "" && !t.expired()
} }
// tokenFromInternal maps an *internal.Token struct into // tokenFromInternal maps an *internal.Token struct into
// a *Token struct. // a *Token struct.
func tokenFromInternal(t *internal.Token) *Token { func tokenFromInternal(t *internal.Token) *Token {
skipping to change at line 154 skipping to change at line 157
RefreshToken: t.RefreshToken, RefreshToken: t.RefreshToken,
Expiry: t.Expiry, Expiry: t.Expiry,
raw: t.Raw, raw: t.Raw,
} }
} }
// retrieveToken takes a *Config and uses that to retrieve an *internal.Token. // retrieveToken takes a *Config and uses that to retrieve an *internal.Token.
// This token is then mapped from *internal.Token into an *oauth2.Token which is returned along // This token is then mapped from *internal.Token into an *oauth2.Token which is returned along
// with an error.. // with an error..
func retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) { func retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) {
tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endp oint.TokenURL, v) tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endp oint.TokenURL, v, internal.AuthStyle(c.Endpoint.AuthStyle))
if err != nil { if err != nil {
if rErr, ok := err.(*internal.RetrieveError); ok { if rErr, ok := err.(*internal.RetrieveError); ok {
return nil, (*RetrieveError)(rErr) return nil, (*RetrieveError)(rErr)
} }
return nil, err return nil, err
} }
return tokenFromInternal(tk), nil return tokenFromInternal(tk), nil
} }
// RetrieveError is the error returned when the token endpoint returns a // RetrieveError is the error returned when the token endpoint returns a
 End of changes. 3 change blocks. 
2 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)