cliauthorizationflow

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client contains an authorized http client. That is, the auth token is automatically set on all request headers.

func NewClient

func NewClient(ctx context.Context, config *Config, tokenStorage TokenStorage) (*Client, error)

NewClient creates a new client with the specified authorization parameters

func (*Client) Persist

func (a *Client) Persist()

Persist will save the current token to storage

type Config

type Config struct {
	// ClientID is the application's ID.
	ClientID string
	// ClientSecret is the application's secret.
	ClientSecret string
	// AuthorizationURL contains the resource server's authorize endpoint URL
	AuthorizationURL string
	// TokenURL contains the resource server's token endpoint URL
	TokenURL string
	// Scope specifies optional requested permissions.
	Scopes []string
	// CallbackPort specifies which local port to use for the auth callback (default: 8080)
	CallbackPort int
}

Config describes a typical 3-legged OAuth2 flow, with both the client application information and the server's endpoint URLs.

type TokenStorage

type TokenStorage interface {
	Get(string) (*oauth2.Token, error)
	Save(string, *oauth2.Token) error
}

TokenStorage is used to cache and retrieve tokens WIP - this doesn't yet support keying off of user or auth service

Jump to

Keyboard shortcuts

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