Documentation
¶
Overview ¶
Package github implements theauth.Provider against GitHub's OAuth 2.0 endpoints. Import this package only when you want GitHub sign in; the root theauth package has no hard dependency on it.
Package github implements theauth.Provider against GitHub's OAuth 2.0 endpoints. Import this package only when you want GitHub sign-in; the root theauth package has no hard dependency on it.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a GitHub theauth.Provider with the supplied Config. Required fields: ClientID, ClientSecret.
Example ¶
ExampleNew constructs a GitHub OAuth provider with the minimum required configuration. Pass the returned value into theauth.Config.Providers.
package main
import (
"fmt"
"github.com/glincker/theauth-go/provider/github"
)
func main() {
p := github.New(github.Config{
ClientID: "client-id",
ClientSecret: "client-secret",
})
fmt.Println(p.Name())
}
Output: github
Types ¶
type Config ¶
type Config struct {
ClientID string
ClientSecret string
Scopes []string
// Endpoint overrides for tests / GitHub Enterprise. Leave empty in
// production to hit github.com directly.
AuthorizeURL string
TokenURL string
UserURL string
EmailsURL string
// HTTPClient lets callers inject a custom client (timeouts, transport
// instrumentation, proxy). Defaults to a fresh client with httpTimeout.
HTTPClient *http.Client
}
Config is the provider's wiring. ClientID + ClientSecret are required; everything else has a sensible default. Scopes default to read:user + user:email when nil.