Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearToken ¶
func ClearToken() error
ClearToken removes the authentication token from the OS credential manager
Types ¶
type AuthToken ¶
type AuthToken struct {
// GitHub OAuth Token
GitHubToken string `json:"github_token"`
GitHubTokenType string `json:"github_token_type"`
GitHubScopes []string `json:"github_scopes"`
// MoMorph Platform Token
MoMorphToken string `json:"momorph_token"`
MoMorphExpiresAt time.Time `json:"momorph_expires_at"`
// User Information
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
Email string `json:"email"`
UserID string `json:"user_id"`
// Metadata
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
AuthToken stores both GitHub OAuth token and MoMorph platform token
func (*AuthToken) NeedsRefresh ¶
NeedsRefresh checks if the token needs refresh (expires within 24 hours)
type DeviceCodeResponse ¶
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 represents GitHub's device code response
func RequestDeviceCode ¶
func RequestDeviceCode(ctx context.Context) (*DeviceCodeResponse, error)
RequestDeviceCode requests a device code from GitHub
type GitHubUser ¶
type GitHubUser struct {
Login string `json:"login"`
ID int `json:"id"`
AvatarURL string `json:"avatar_url"`
Name string `json:"name"`
Email string `json:"email"`
}
GitHubUser represents a GitHub user
func GetAuthenticatedUser ¶
func GetAuthenticatedUser(ctx context.Context, accessToken string) (*GitHubUser, error)
GetAuthenticatedUser retrieves the authenticated user's information from GitHub
type MoMorphTokenResponse ¶
type MoMorphTokenResponse struct {
Token string `json:"token"`
}
MoMorphTokenResponse represents the response from MoMorph token exchange
func ExchangeGitHubToken ¶
func ExchangeGitHubToken(ctx context.Context, githubToken string) (*MoMorphTokenResponse, error)
ExchangeGitHubToken exchanges a GitHub OAuth token for a MoMorph platform token
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
Error string `json:"error"`
ErrorDesc string `json:"error_description"`
}
TokenResponse represents GitHub's token response
func PollForToken ¶
PollForToken polls GitHub for the access token