Documentation ¶
Index ¶
- Variables
- func CondVal(v string) []string
- func ContextClient(ctx context.Context) (*http.Client, error)
- func RegisterContextClientFunc(fn ContextClientFunc)
- func RetrieveToken(ctx context.Context, callback func(req *http.Request), tokenURL string, ...) (*oauth2.Token, echo.H, error)
- type Config
- type ContextClientFunc
- type ContextKey
- type Token
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = com.HTTPClientWithTimeout(10 * time.Second)
Functions ¶
func RegisterContextClientFunc ¶
func RegisterContextClientFunc(fn ContextClientFunc)
Types ¶
type Config ¶
func (*Config) Exchange ¶
func (c *Config) Exchange(ctx context.Context, code interface{}, callbacks ...func(*http.Request)) (*Token, error)
Exchange converts an authorization code into a token.
It is used after a resource provider redirects the user back to the Redirect URI (the URL obtained from AuthCodeURL).
The HTTP client to use is derived from the context. If a client is not provided via the context, http.DefaultClient is used.
The code will be in the *http.Request.FormValue("code"). Before calling Exchange, be sure to validate FormValue("state").
type ContextClientFunc ¶
ContextClientFunc is a func which tries to return an *http.Client given a Context value. If it returns an error, the search stops with that error. If it returns (nil, nil), the search continues down the list of registered funcs.
type ContextKey ¶
type ContextKey struct{}
ContextKey is just an empty struct. It exists so HTTPClient can be an immutable public variable with a unique type. It's immutable because nobody else can create a ContextKey, being unexported.
var HTTPClient ContextKey
HTTPClient is the context key to use with golang.org/x/net/context's WithValue function to associate an *http.Client value with a context.