oauth2

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2022 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = com.HTTPClientWithTimeout(10 * time.Second)

Functions

func CondVal

func CondVal(v string) []string

func ContextClient

func ContextClient(ctx context.Context) (*http.Client, error)

func RegisterContextClientFunc

func RegisterContextClientFunc(fn ContextClientFunc)

func RetrieveToken

func RetrieveToken(ctx context.Context, callback func(req *http.Request), tokenURL string, v url.Values) (*oauth2.Token, echo.H, error)

Types

type Config

type Config struct {
	*oauth2.Config
}

func NewConfig

func NewConfig(conf *oauth2.Config) *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

type ContextClientFunc func(context.Context) (*http.Client, error)

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.

type Token

type Token struct {
	*oauth2.Token

	// raw optionally contains extra metadata from the server
	// when updating a token.
	Raw echo.H
}

func NewToken

func NewToken(token *oauth2.Token, raw echo.H) *Token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL