github

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 13 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

Overview

Package github is a provider of GitHub, or GitHub Enterprise, which is signed in with at GitHub, as an OAuth app, which isn't OpenID Connect, so the identity is the user GitHub's API says the token is for.

Index

Constants

View Source
const (

	// DefaultURL and DefaultAPIURL are GitHub's, rather than GitHub
	// Enterprise's
	DefaultURL    = "https://github.com"
	DefaultAPIURL = "https://api.github.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Opt

type Opt func(*Provider) error

Opt is an option of a provider

func WithClient

func WithClient(opts ...client.ClientOpt) Opt

WithClient sets options of the client which exchanges codes, and calls the API, such as client.OptTracer, or OptTimeout

func WithOrganizations

func WithOrganizations() Opt

WithOrganizations asks to read the user's organisations, which are the identity's groups

func WithURL

func WithURL(web, api string) Opt

WithURL is GitHub Enterprise, at its URL, and its API's

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is GitHub, whose OAuth app is a credential

func New

func New(credentials credential.CredentialProvider, key string, opts ...Opt) (*Provider, error)

New returns GitHub, named github, whose OAuth app is the credential at the key: an OAuthClient, with its client ID and secret. It asks to read the user, and their email addresses.

func (*Provider) AuthCodeURL

func (p *Provider) AuthCodeURL(ctx context.Context, redirectURL, state, verifier string) (string, error)

AuthCodeURL returns the URL of GitHub's sign-in page, which redirects to the redirect URL with a code, and the state, with the S256 challenge of the verifier

func (*Provider) Exchange

func (p *Provider) Exchange(ctx context.Context, credential schema.Credential) (*schema.Identity, error)

Exchange exchanges the code, with its verifier, for a token, and returns the identity of the user it's for: their ID, which doesn't change, their name, or login, their primary email address, and their organisations, when they're asked for

func (*Provider) Meta

func (p *Provider) Meta() schema.ProviderMeta

Meta describes the provider

Jump to

Keyboard shortcuts

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