auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTokenCache

func ClearTokenCache()

ClearTokenCache clears the token cache.

func SetTokenForTest added in v0.1.1

func SetTokenForTest(clientID string, token *Token)

SetTokenForTest injects a token into the cache for testing.

Types

type KeyringStore

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

KeyringStore stores credentials in the OS keyring.

func (*KeyringStore) DeleteCredentials

func (s *KeyringStore) DeleteCredentials(profile string) error

DeleteCredentials removes credentials from the keyring.

func (*KeyringStore) GetCredentials

func (s *KeyringStore) GetCredentials(profile string) (string, string, error)

GetCredentials retrieves credentials from the keyring.

func (*KeyringStore) SetCredentials

func (s *KeyringStore) SetCredentials(profile, clientID, clientSecret string) error

SetCredentials stores credentials in the keyring.

type Store

type Store interface {
	GetCredentials(profile string) (clientID, clientSecret string, err error)
	SetCredentials(profile, clientID, clientSecret string) error
	DeleteCredentials(profile string) error
}

Store provides credential storage.

func OpenKeyring

func OpenKeyring() (Store, error)

OpenKeyring opens the default keyring store.

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
	Scope       string `json:"scope"`
	ExpiresAt   time.Time
}

Token represents an OAuth2 access token.

func GetAccessToken

func GetAccessToken(ctx context.Context, clientID, clientSecret string) (*Token, error)

GetAccessToken retrieves an access token using client credentials.

func (*Token) IsExpired

func (t *Token) IsExpired() bool

IsExpired checks if the token is expired or about to expire.

Jump to

Keyboard shortcuts

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