Documentation
¶
Index ¶
- Variables
- func Authorize(ctx context.Context, opts AuthorizeOptions) (string, error)
- func EnsureCertificate() (certPath, keyPath string, err error)
- func GetAuthenticatedEmail(client string) (string, error)
- func IsKeychainLockedError(msg string) bool
- func ParseTokenKey(k string) (client, email string, ok bool)
- type AuthorizeOptions
- type KeyringStore
- func (s *KeyringStore) DeleteToken(client, email string) error
- func (s *KeyringStore) GetToken(client, email string) (Token, error)
- func (s *KeyringStore) Keys() ([]string, error)
- func (s *KeyringStore) ListTokens() ([]Token, error)
- func (s *KeyringStore) SetToken(client, email string, tok Token) error
- type RefreshTokenSource
- type Store
- type Token
- type TokenSource
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotAuthenticated = errors.New("not authenticated")
Functions ¶
func EnsureCertificate ¶
EnsureCertificate returns paths to cert and key files, generating them if needed.
func GetAuthenticatedEmail ¶
GetAuthenticatedEmail returns the email for the authenticated account, or error if not authenticated.
func IsKeychainLockedError ¶
func ParseTokenKey ¶
Types ¶
type AuthorizeOptions ¶
type KeyringStore ¶
type KeyringStore struct {
// contains filtered or unexported fields
}
func (*KeyringStore) DeleteToken ¶
func (s *KeyringStore) DeleteToken(client, email string) error
func (*KeyringStore) GetToken ¶
func (s *KeyringStore) GetToken(client, email string) (Token, error)
func (*KeyringStore) Keys ¶
func (s *KeyringStore) Keys() ([]string, error)
func (*KeyringStore) ListTokens ¶
func (s *KeyringStore) ListTokens() ([]Token, error)
type RefreshTokenSource ¶ added in v0.1.4
type RefreshTokenSource struct {
// contains filtered or unexported fields
}
RefreshTokenSource is a simple token source that uses a refresh token directly. Used during initial login before we know the user's email.
func NewRefreshTokenSource ¶ added in v0.1.4
func NewRefreshTokenSource(client, refreshToken string) *RefreshTokenSource
NewRefreshTokenSource creates a token source from a refresh token directly.
type Store ¶
type Store interface {
Keys() ([]string, error)
SetToken(client, email string, tok Token) error
GetToken(client, email string) (Token, error)
DeleteToken(client, email string) error
ListTokens() ([]Token, error)
}
func OpenDefault ¶
type TokenSource ¶
type TokenSource struct {
// contains filtered or unexported fields
}
TokenSource provides OAuth2 tokens with lazy refresh on 401. Access tokens are kept in memory only; refresh tokens are stored in keyring.
func NewTokenSource ¶
func NewTokenSource(client, email string, store Store) *TokenSource
func (*TokenSource) Invalidate ¶
func (ts *TokenSource) Invalidate()
Invalidate marks the current access token as invalid, forcing a refresh on next Token() call.
Click to show internal directories.
Click to hide internal directories.