cache

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: BSD-3-Clause Imports: 9 Imported by: 2

Documentation

Overview

Package cache defines the Credentials tokensource which allows caching of oauth2 tokens

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New creates a caching tokensource for uses as an oauth2.TokenSource and ctxclient.Func

Types

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

type TokenSourceParam

type TokenSourceParam func(*tokenSource)

TokenSourceParam update a clientFunc

func InitialToken

func InitialToken(tk *oauth2.Token) TokenSourceParam

InitialToken is a TokenSourceParam used for setting the initial token for a TokenSource object

func TokenCacheDuration

func TokenCacheDuration(dur time.Duration) TokenSourceParam

TokenCacheDuration is a TokenSourceParam used to set the duration time for a new token

Jump to

Keyboard shortcuts

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