internal

package
v0.0.0-...-7b0ec94 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2016 License: Apache-2.0, BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package internal contains support packages for oauth2 package.

Package internal contains support packages for oauth2 package.

Package internal contains support packages for oauth2 package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CondVal

func CondVal(v string) []string

func ContextClient

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

func ContextTransport

func ContextTransport(ctx context.Context) http.RoundTripper

func ParseINI

func ParseINI(ini io.Reader) (map[string]map[string]string, error)

func ParseKey

func ParseKey(key []byte) (*rsa.PrivateKey, error)

ParseKey converts the binary contents of a private key file to an *rsa.PrivateKey. It detects whether the private key is in a PEM container or not. If so, it extracts the the private key from PEM container before conversion. It only supports PEM containers with no passphrase.

func RegisterContextClientFunc

func RegisterContextClientFunc(fn ContextClientFunc)

Types

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 ErrorTransport

type ErrorTransport struct{ Err error }

ErrorTransport returns the specified error on RoundTrip. This RoundTripper should be used in rare error cases where error handling can be postponed to response handling time.

func (ErrorTransport) RoundTrip

func (t ErrorTransport) RoundTrip(*http.Request) (*http.Response, error)

type Token

type Token struct {
	// AccessToken is the token that authorizes and authenticates
	// the requests.
	AccessToken string

	// TokenType is the type of token.
	// The Type method returns either this or "Bearer", the default.
	TokenType string

	// RefreshToken is a token that's used by the application
	// (as opposed to the user) to refresh the access token
	// if it expires.
	RefreshToken string

	// Expiry is the optional expiration time of the access token.
	//
	// If zero, TokenSource implementations will reuse the same
	// token forever and RefreshToken or equivalent
	// mechanisms for that TokenSource will not be used.
	Expiry time.Time

	// Raw optionally contains extra metadata from the server
	// when updating a token.
	Raw interface{}
}

Token represents the crendentials used to authorize the requests to access protected resources on the OAuth 2.0 provider's backend.

This type is a mirror of oauth2.Token and exists to break an otherwise-circular dependency. Other internal packages should convert this Token into an oauth2.Token before use.

func RetrieveToken

func RetrieveToken(ctx context.Context, ClientID, ClientSecret, TokenURL string, v url.Values) (*Token, error)

Jump to

Keyboard shortcuts

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