auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachingClientFunc

func CachingClientFunc(tc TokenCache, ts oauth2.TokenSource, op ...ClientFuncParam) (ctxclient.Func, error)

CachingClientFunc returns ctxclient func returning a token caching http.Client

Types

type ClientFuncParam

type ClientFuncParam func(*Credentials)

ClientFuncParam update a clientFunc

func InitialToken

func InitialToken(tk *oauth2.Token) ClientFuncParam

InitialToken sets the initial token for a client caching object

func TokenCacheDuration

func TokenCacheDuration(dur time.Duration) ClientFuncParam

TokenCacheDuration set the duration time for a new token

type Credentials

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

Credentials implements a simple caching structure for oauth tokens.

func (*Credentials) Client

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

Client returns an http client that authorizes calls using the credentials reuse and caching logic. May be used as a ctxclient.Func.

func (*Credentials) Token

func (cc *Credentials) Token(ctx context.Context) (*oauth2.Token, error)

Token returns a valid oauth token for authorizing a restapi call

type FileCache

type FileCache struct {
	Filename string
	// Don't report save error so not stopping program
	IgnorePersistsErr bool
	// contains filtered or unexported fields
}

FileCache creates a file based cache

func (*FileCache) Get

func (fc *FileCache) Get(ctx context.Context) (*oauth2.Token, error)

Get decodes file content into a token

func (*FileCache) Save

func (fc *FileCache) Save(ctx context.Context, tk *oauth2.Token) error

Save overwrites the cache file

type TokenCache

type TokenCache interface {
	Save(context.Context, *oauth2.Token) error
	Get(context.Context) (*oauth2.Token, error)
}

TokenCache provides the methods for saving and retreiving tokens

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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