Documentation
¶
Index ¶
- Variables
- func Clear(id Identity) error
- func Save(id Identity, token string, expiresAt time.Time, userID string) error
- func SetFallbackPathForTest(path string) (restore func())
- func SetOpenFileKeyringForTest(fn func() (keyring.Keyring, error)) (restore func())
- func SetOpenKeyringForTest(fn func() (keyring.Keyring, error)) (restore func())
- type CachedToken
- type Identity
Constants ¶
This section is empty.
Variables ¶
var (
ErrAmbiguousAccount = errors.New("multiple cached accounts; specify --email")
)
Functions ¶
func Clear ¶
Clear removes the identity's local token cache from reachable backends. An unavailable backend is tolerated if another opens, but removal failures from an opened backend are returned. This does not revoke tokens at the service.
func SetFallbackPathForTest ¶
func SetFallbackPathForTest(path string) (restore func())
SetFallbackPathForTest isolates legacy plaintext-cache migration tests. Production code uses the default location only to remove pre-upgrade entries.
func SetOpenFileKeyringForTest ¶
SetOpenFileKeyringForTest swaps the file-backed fallback opener. Use with SetOpenKeyringForTest to exercise the fallback path in isolation.
func SetOpenKeyringForTest ¶
SetOpenKeyringForTest swaps the keyring opener; it returns a restore func. Not safe for concurrent tests; intended for isolated test scenarios.
Types ¶
type CachedToken ¶
type CachedToken struct {
Token string `json:"token"`
ExpiresAt time.Time `json:"expires_at"`
UserID string `json:"user_id,omitempty"`
}
func Load ¶
func Load(id Identity) (*CachedToken, error)
Load returns the cached token for the given Identity, if present and unexpired. Tokens are namespaced by Identity (base URL + client ID + email) — not by UserID — because a single OAuth principal (email) can legitimately act on multiple household userIDs. The cached UserID is informational metadata for callers that want to recover "which userID was primary at auth time."