Documentation
¶
Overview ¶
Package auth - OAuth 2.0 Device Flow implementation
Package auth handles authentication for GitScrum CLI
Index ¶
Constants ¶
View Source
const ( // OAuth endpoints (matching Laravel API routes) DeviceCodeEndpoint = "/oauth/device/code" TokenEndpoint = "/oauth/device/token" // Grant types GrantTypeDeviceCode = "urn:ietf:params:oauth:grant-type:device_code" )
Variables ¶
View Source
var ( ErrNotAuthenticated = errors.New("not authenticated. Run 'gitscrum login' to authenticate") ErrTokenExpired = errors.New("token expired. Run 'gitscrum login' to re-authenticate") )
Errors
Functions ¶
Types ¶
type DeviceAuthenticator ¶
type DeviceAuthenticator struct {
BaseURL string
ClientID string
Scopes string
HTTPClient *http.Client
}
DeviceAuthenticator handles OAuth Device Flow
func NewDeviceAuthenticator ¶
func NewDeviceAuthenticator(baseURL, clientID, scopes string) *DeviceAuthenticator
NewDeviceAuthenticator creates a new authenticator
func (*DeviceAuthenticator) OpenBrowser ¶
func (a *DeviceAuthenticator) OpenBrowser(verificationURI string) error
OpenBrowser opens the verification URL in the default browser
func (*DeviceAuthenticator) PollForToken ¶
func (a *DeviceAuthenticator) PollForToken(deviceCode string, interval, expiresIn int) (*Token, error)
PollForToken polls the token endpoint until authorization is complete
func (*DeviceAuthenticator) StartDeviceFlow ¶
func (a *DeviceAuthenticator) StartDeviceFlow() (*DeviceCodeResponse, error)
StartDeviceFlow initiates the device authorization flow
type DeviceCodeResponse ¶
type DeviceCodeResponse struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
VerificationURIComplete string `json:"verification_uri_complete,omitempty"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
DeviceCodeResponse from device authorization endpoint
type Token ¶
type Token struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Token represents the OAuth token
Click to show internal directories.
Click to hide internal directories.