auth

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package auth provides GitHub OAuth authentication via Device Code flow. Tokens are stored in the OS keychain (macOS/Windows) or file-based storage (Linux/WSL).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAuthenticated = errors.New("not authenticated")

ErrNotAuthenticated indicates no stored authentication token was found.

Functions

func GetToken

func GetToken() (string, error)

GetToken retrieves the stored GitHub token from the OS keychain or file storage.

func Logout

func Logout() error

Logout removes the stored GitHub token from keychain and file storage.

Types

type DeviceCode

type DeviceCode 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"`
}

DeviceCode represents the response from GitHub's device code request.

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Scope       string `json:"scope"`
}

Token represents a GitHub OAuth access token.

func Login

func Login(ctx context.Context) (*Token, error)

Login performs GitHub OAuth Device Code flow authentication. It displays a URL and code for the user to authorize, then stores the token in the keychain.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL