Documentation
¶
Index ¶
- Variables
- func Authorize(ctx context.Context, creds OAuthCredentials, opts AuthorizeOptions) (string, error)
- func DefaultRedirectURI(port int) string
- func IsKeychainLockedError(msg string) bool
- func ResolveRedirectURI(creds OAuthCredentials, port int) string
- type AuthorizeOptions
- type KeyringStore
- func (s *KeyringStore) CredentialsExists() (bool, error)
- func (s *KeyringStore) DeleteCredentials() error
- func (s *KeyringStore) DeleteToken() error
- func (s *KeyringStore) GetCredentials() (OAuthCredentials, error)
- func (s *KeyringStore) GetToken() (Token, error)
- func (s *KeyringStore) SetCredentials(creds OAuthCredentials) error
- func (s *KeyringStore) SetToken(tok Token) error
- type OAuthCredentials
- type OAuthTokenSource
- type RefreshTokenSource
- type Store
- type TestTokenSource
- type Token
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoToken is returned when no token is stored in the keyring. ErrNoToken = errors.New("no token found") ErrNoCredentials = errors.New("no oauth credentials configured") )
View Source
var ErrNotAuthenticated = errors.New("not authenticated")
Functions ¶
func Authorize ¶
func Authorize(ctx context.Context, creds OAuthCredentials, opts AuthorizeOptions) (string, error)
func DefaultRedirectURI ¶
func IsKeychainLockedError ¶
func ResolveRedirectURI ¶
func ResolveRedirectURI(creds OAuthCredentials, port int) string
Types ¶
type KeyringStore ¶
type KeyringStore struct {
// contains filtered or unexported fields
}
func (*KeyringStore) CredentialsExists ¶
func (s *KeyringStore) CredentialsExists() (bool, error)
func (*KeyringStore) DeleteCredentials ¶
func (s *KeyringStore) DeleteCredentials() error
func (*KeyringStore) DeleteToken ¶
func (s *KeyringStore) DeleteToken() error
func (*KeyringStore) GetCredentials ¶
func (s *KeyringStore) GetCredentials() (OAuthCredentials, error)
func (*KeyringStore) GetToken ¶
func (s *KeyringStore) GetToken() (Token, error)
func (*KeyringStore) SetCredentials ¶
func (s *KeyringStore) SetCredentials(creds OAuthCredentials) error
func (*KeyringStore) SetToken ¶
func (s *KeyringStore) SetToken(tok Token) error
type OAuthCredentials ¶
type OAuthTokenSource ¶
type OAuthTokenSource struct {
// contains filtered or unexported fields
}
OAuthTokenSource provides OAuth2 tokens with lazy refresh. Access tokens are kept in memory only; refresh tokens are stored in keyring.
func NewOAuthTokenSource ¶
func NewOAuthTokenSource(store Store, creds OAuthCredentials) *OAuthTokenSource
NewOAuthTokenSource creates an OAuth token source using stored credentials.
func (*OAuthTokenSource) Invalidate ¶
func (ts *OAuthTokenSource) Invalidate()
Invalidate marks the current access token as invalid, forcing a refresh on next Token() call.
type RefreshTokenSource ¶
type RefreshTokenSource struct {
// contains filtered or unexported fields
}
RefreshTokenSource uses a refresh token directly (used during login).
func NewRefreshTokenSource ¶
func NewRefreshTokenSource(creds OAuthCredentials, refreshToken string) *RefreshTokenSource
NewRefreshTokenSource creates a token source from a refresh token directly.
type Store ¶
type Store interface {
SetToken(tok Token) error
GetToken() (Token, error)
DeleteToken() error
SetCredentials(creds OAuthCredentials) error
GetCredentials() (OAuthCredentials, error)
DeleteCredentials() error
CredentialsExists() (bool, error)
}
func OpenDefault ¶
type TestTokenSource ¶
type TestTokenSource struct {
// contains filtered or unexported fields
}
TestTokenSource provides a static token from the test token or environment.
func NewTestTokenSource ¶
func NewTestTokenSource(store Store) *TestTokenSource
Click to show internal directories.
Click to hide internal directories.