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 ¶
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 ¶
Opt is an option of a provider
func WithClient ¶
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
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