Source File
token.go
Belonging Package
golang.org/x/oauth2
package oauth2
import (
)
const expiryDelta = 10 * time.Second
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
raw interface{}
}
func ( *Token) ( string) interface{} {
if , := .raw.(map[string]interface{}); {
return []
}
, := .raw.(url.Values)
if ! {
return nil
}
:= .Get()
switch := strings.TrimSpace(); strings.Count(, ".") {
case 0: // Contains no "."; try to parse as int
if , := strconv.ParseInt(, 10, 64); == nil {
return
}
case 1: // Contains a single "."; try to parse as float
if , := strconv.ParseFloat(, 64); == nil {
return
}
}
return
}
func ( *Token) () bool {
return != nil && .AccessToken != "" && !.expired()
}
func ( *internal.Token) *Token {
if == nil {
return nil
}
return &Token{
AccessToken: .AccessToken,
TokenType: .TokenType,
RefreshToken: .RefreshToken,
Expiry: .Expiry,
raw: .Raw,
}
}
func ( context.Context, *Config, url.Values) (*Token, error) {
, := internal.RetrieveToken(, .ClientID, .ClientSecret, .Endpoint.TokenURL, , internal.AuthStyle(.Endpoint.AuthStyle))
if != nil {
if , := .(*internal.RetrieveError); {
return nil, (*RetrieveError)()
}
return nil,
}
return tokenFromInternal(), nil
}
type RetrieveError struct {
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |