oauthstore

package
v0.0.0-...-b631e0d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken(ctx context.Context, conf Config) (*oauth2.Token, error)

GetToken retrieves a github oauth2 token

func StorageTokenSource

func StorageTokenSource(ctx context.Context, c *Config, t *oauth2.Token) oauth2.TokenSource

StorageTokenSource will be used by our config.TokenSource method

Types

type Config

type Config struct {
	*oauth2.Config
	Storage
}

Config wraps the default oauth2.Config and adds our storage

func (*Config) Client

func (c *Config) Client(ctx context.Context, t *oauth2.Token) *http.Client

Client is attached to our TokenSource

func (*Config) Exchange

func (c *Config) Exchange(ctx context.Context, code string) (*oauth2.Token, error)

Exchange stores a token after retrieval

func (*Config) TokenSource

func (c *Config) TokenSource(ctx context.Context, t *oauth2.Token) oauth2.TokenSource

TokenSource can be passed a token which is stored, or when a new one is retrieved, that's stored

type FileStorage

type FileStorage struct {
	Path string
	// contains filtered or unexported fields
}

FileStorage satisfies our storage interface

func (*FileStorage) GetToken

func (f *FileStorage) GetToken() (*oauth2.Token, error)

GetToken retrieves a token from a file

func (*FileStorage) SetToken

func (f *FileStorage) SetToken(t *oauth2.Token) error

SetToken creates, truncates, then stores a token in a file

type Storage

type Storage interface {
	GetToken() (*oauth2.Token, error)
	SetToken(*oauth2.Token) error
}

Storage is our generic storage interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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