Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is the expected error if the token is not found in the keyring ErrNotFound = errors.New("failed retrieving token from keyring") // ErrInvalidToken is the expected error if the token is not a valid one ErrInvalidToken = errors.New("invalid token") )
Functions ¶
This section is empty.
Types ¶
type KeyringRepository ¶
type KeyringRepository struct {
// contains filtered or unexported fields
}
KeyringRepository represents a repository provided by different secrets backend using `99designs/keyring` package.
func NewKeyringRepository ¶
func NewKeyringRepository(backend string, promptFunc *keyring.PromptFunc, keyringDir string) (*KeyringRepository, error)
NewKeyringRepository creates a new repository backend could be used to select which backed will be used. If it's empty the library will select the most suitable depending OS.
All currently supported secure storage backends:
SecretServiceBackend BackendType = "secret-service" KeychainBackend BackendType = "keychain" KWalletBackend BackendType = "kwallet" WinCredBackend BackendType = "wincred" FileBackend BackendType = "file" PassBackend BackendType = "pass"
func (*KeyringRepository) Close ¶
func (r *KeyringRepository) Close() error
Close closes the keyring repository.
type Repository ¶ added in v1.2.0
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 ¶ added in v1.2.0
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) RetrieveToken ¶
func (tm *TokenManager) RetrieveToken(email string) (*oauth2.Token, error)
RetrieveToken returns the Token from the repository.
func (*TokenManager) StoreToken ¶
func (tm *TokenManager) StoreToken(email string, token *oauth2.Token) error
StoreToken stores the Token into the repository.