Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeviceCodeResponse ¶ added in v0.2.0
type DeviceCodeResponse struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
DeviceCodeResponse is the initial response from the device auth endpoint.
type DeviceFlow ¶ added in v0.2.0
type DeviceFlow struct {
Config DeviceFlowConfig
HTTPClient *http.Client
}
DeviceFlow implements the OAuth 2.0 Device Authorization Grant (RFC 8628).
func NewDeviceFlow ¶ added in v0.2.0
func NewDeviceFlow(cfg DeviceFlowConfig) *DeviceFlow
NewDeviceFlow creates a device flow handler.
func (*DeviceFlow) PollForToken ¶ added in v0.2.0
func (df *DeviceFlow) PollForToken(ctx context.Context, deviceCode string) (*TokenResponse, error)
PollForToken polls the token endpoint until the user authorizes or timeout.
func (*DeviceFlow) RequestCode ¶ added in v0.2.0
func (df *DeviceFlow) RequestCode(ctx context.Context) (*DeviceCodeResponse, error)
RequestCode initiates the device flow and returns the user code + verification URL.
type DeviceFlowConfig ¶ added in v0.2.0
type DeviceFlowConfig struct {
ClientID string
DeviceAuthURL string // e.g. "https://github.com/login/device/code"
TokenURL string // e.g. "https://github.com/login/oauth/access_token"
Scopes []string
PollInterval time.Duration
ExpiresIn time.Duration
}
DeviceFlowConfig holds OAuth device flow configuration.
type OAuthFlow ¶
OAuthFlow handles OAuth authentication flow.
type SecureStorage ¶
type SecureStorage struct {
// contains filtered or unexported fields
}
SecureStorage handles secure token storage using OS keychain/keyring.
func NewSecureStorage ¶
func NewSecureStorage(service string) *SecureStorage
NewSecureStorage creates a new secure storage.
func (*SecureStorage) Get ¶
func (s *SecureStorage) Get(account string) (string, error)
Get retrieves a token from secure storage.
func (*SecureStorage) Set ¶
func (s *SecureStorage) Set(account, token string) error
Set stores a token in secure storage.
type TokenResponse ¶ added in v0.2.0
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
}
TokenResponse is the final token from the OAuth flow.
type TokenStore ¶
type TokenStore struct {
// contains filtered or unexported fields
}
TokenStore manages authentication tokens.
func (*TokenStore) Get ¶
func (t *TokenStore) Get(provider string) string
Get returns a token for a provider.
func (*TokenStore) Has ¶
func (t *TokenStore) Has(provider string) bool
Has returns true if a token exists for a provider.
func (*TokenStore) Set ¶
func (t *TokenStore) Set(provider, token string)
Set sets a token for a provider.