tokenmanager

package
v0.0.0-...-5c8abdd Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTokenNotFound is the expected error if the token is not found.
	ErrTokenNotFound = errors.New("token was not found")

	// ErrInvalidToken is the expected error if the token is not a valid.
	ErrInvalidToken = errors.New("invalid token")
)

Functions

This section is empty.

Types

type FileRepository

type FileRepository struct {
	// contains filtered or unexported fields
}

func NewFileRepository

func NewFileRepository(dir string) (*FileRepository, error)

func (*FileRepository) Close

func (r *FileRepository) Close() error

Close closes the keyring repository.

func (*FileRepository) Get

func (r *FileRepository) Get(email string) (*oauth2.Token, error)

getToken returns the specified token from the repository.

func (*FileRepository) Set

func (r *FileRepository) Set(email string, token *oauth2.Token) error

Set stores a token into the OS keyring.

type Repository

type Repository interface {
	Get(key string) (*oauth2.Token, error)
	Set(key string, token *oauth2.Token) error
	Close() error
}

Repository is responsible to store tokens somewhere.

type TokenManager

type TokenManager struct {
	// contains filtered or unexported fields
}

TokenManager allows to store and retrieve Token from a repository.

func New

func New(repo Repository) *TokenManager

New returns a TokenManager using the specified repo.

func (*TokenManager) Close

func (tm *TokenManager) Close() error

Close closes the token repository.

func (*TokenManager) Get

func (tm *TokenManager) Get(email string) (*oauth2.Token, error)

Get returns the token, associated with email, from the repository.

func (*TokenManager) Put

func (tm *TokenManager) Put(email string, token *oauth2.Token) error

Put stores the token, using email as key, into the repository.

Jump to

Keyboard shortcuts

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