ghauth

package
v0.160.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoToken = errors.New("no token stored in memory")

ErrNoToken is returned by GetToken when the in-memory token store is active and no token has been saved yet.

Functions

func DeleteToken

func DeleteToken() error

DeleteToken removes the GitHub OAuth token from the active store (the system keyring by default, or process memory after UseMemoryStore).

func GetToken

func GetToken() (*oauth2.Token, error)

GetToken retrieves the GitHub OAuth token from the active store (the system keyring by default, or process memory after UseMemoryStore).

func LimitScope added in v0.159.0

func LimitScope(scope string)

LimitScope fixes the scope of all subsequent device-code requests in this process. The first call wins.

func PollForToken

func PollForToken(ctx context.Context, clientID, clientSecret, deviceCode string, interval int, onAttempt func(attempt int)) (*oauth2.Token, error)

PollForToken polls GitHub for an access token.

func SaveToken

func SaveToken(token *oauth2.Token) error

SaveToken stores the GitHub OAuth token in the active store (the system keyring by default, or process memory after UseMemoryStore).

func UseMemoryStore added in v0.159.0

func UseMemoryStore()

UseMemoryStore switches SaveToken, GetToken and DeleteToken to an in-memory store for the rest of the process so the OS keyring is never touched. Calling it more than once is a no-op and preserves any stored token.

Types

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 the response from GitHub's device code request.

func RequestDeviceCode

func RequestDeviceCode(ctx context.Context, clientID string) (*DeviceCodeResponse, error)

RequestDeviceCode requests a device code from GitHub.

func RequestDeviceCodeWithScope added in v0.159.0

func RequestDeviceCodeWithScope(ctx context.Context, clientID, scope string) (*DeviceCodeResponse, error)

RequestDeviceCodeWithScope requests a device code from GitHub for the given OAuth scope.

Jump to

Keyboard shortcuts

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