MCPcopy Create free account
hub / github.com/netlify/gotrue / NewGithubProvider

Function NewGithubProvider

api/provider/github.go:37–61  ·  view source on GitHub ↗

NewGithubProvider creates a Github account provider.

(ext conf.OAuthProviderConfiguration)

Source from the content-addressed store, hash-verified

35
36// NewGithubProvider creates a Github account provider.
37func NewGithubProvider(ext conf.OAuthProviderConfiguration) (OAuthProvider, error) {
38 if err := ext.Validate(); err != nil {
39 return nil, err
40 }
41
42 authHost := chooseHost(ext.URL, defaultGitHubAuthBase)
43 apiHost := chooseHost(ext.URL, defaultGitHubApiBase)
44 if !strings.HasSuffix(apiHost, defaultGitHubApiBase) {
45 apiHost += "/api/v3"
46 }
47
48 return &githubProvider{
49 Config: &oauth2.Config{
50 ClientID: ext.ClientID,
51 ClientSecret: ext.Secret,
52 Endpoint: oauth2.Endpoint{
53 AuthURL: authHost + "/login/oauth/authorize",
54 TokenURL: authHost + "/login/oauth/access_token",
55 },
56 RedirectURL: ext.RedirectURI,
57 Scopes: []string{"user:email"},
58 },
59 APIHost: apiHost,
60 }, nil
61}
62
63func (g githubProvider) GetOAuthToken(code string) (*oauth2.Token, error) {
64 return g.Exchange(oauth2.NoContext, code)

Callers 2

ProviderMethod · 0.92
TestGithubFailFunction · 0.92

Calls 2

chooseHostFunction · 0.85
ValidateMethod · 0.80

Tested by 1

TestGithubFailFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…