Documentation
¶
Index ¶
- Variables
- func DeleteToken() error
- func GetToken() (*oauth2.Token, error)
- func LimitScope(scope string)
- func PollForToken(ctx context.Context, clientID, clientSecret, deviceCode string, interval int, ...) (*oauth2.Token, error)
- func SaveToken(token *oauth2.Token) error
- func UseMemoryStore()
- type DeviceCodeResponse
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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.