Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoPrinter = errors.New("printer is required for device code flow") ErrFlowNotSupported = errors.New("unsupported authentication flow") ErrNoAccounts = errors.New("no accounts found") ErrTokenExpired = errors.New("token has expired") ErrDeclinedScopes = errors.New("scopes have been declined") )
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(config Config, options ...Option) *Authenticator
NewAuthenticator creates a new authenticator with the given configuration.
func (*Authenticator) Authenticate ¶
func (a *Authenticator) Authenticate(ctx context.Context) (public.AuthResult, error)
Authenticate initiates the authentication flow. If the user is already authenticated, the cached token is used. If the user is not authenticated, the user is prompted to authenticate using the configured flow.
func (*Authenticator) GetCurrentAccount ¶
func (*Authenticator) IsAuthenticated ¶
func (a *Authenticator) IsAuthenticated(ctx context.Context) (bool, error)
IsAuthenticated checks if the user is authenticated by checking if there are any cached accounts.
type Config ¶
func ConfigFromBuildProps ¶
func ConfigFromBuildProps() Config
type Option ¶
type Option func(authenticator *Authenticator)
func WithDeviceCodeFlow ¶
WithDeviceCodeFlow configures the authenticator to use the device code flow for authentication. The printer is used to display the device code message to the user.
func WithTokenCache ¶
func WithTokenCache(cache cache.ExportReplace) Option
WithTokenCache configures the authenticator to use a custom token cache.
Click to show internal directories.
Click to hide internal directories.