...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package oauth2
16
17 import (
18 "strings"
19
20 "github.com/palantir/go-githubapp/githubapp"
21 "golang.org/x/oauth2"
22 )
23
24 const (
25 DefaultRoute = "/api/github/auth"
26 )
27
28 func GetConfig(c githubapp.Config, scopes []string) *oauth2.Config {
29 return &oauth2.Config{
30 ClientID: c.OAuth.ClientID,
31 ClientSecret: c.OAuth.ClientSecret,
32 Endpoint: oauth2.Endpoint{
33 AuthURL: joinURL(c.WebURL, "/login/oauth/authorize"),
34 TokenURL: joinURL(c.WebURL, "/login/oauth/access_token"),
35 },
36 Scopes: scopes,
37 }
38 }
39
40 func joinURL(base, path string) string {
41 return strings.TrimSuffix(base, "/") + path
42 }
43
View as plain text