@@ -7,6 +7,7 @@ import (
@@ -32,11 +33,12 @@ func NewGitHubProvider(p *ProviderData) *GitHubProvider {
32 Path: "/login/oauth/access_token",
33 Path: "/login/oauth/access_token",
36+ // ValidationURL is the API Base URL
35 if p.ValidateURL == nil || p.ValidateURL.String() == "" {
37 if p.ValidateURL == nil || p.ValidateURL.String() == "" {
36 p.ValidateURL = &url.URL{
38 p.ValidateURL = &url.URL{
37 Scheme: "https",
39 Scheme: "https",
38 Host: "api.github.com",
40 Host: "api.github.com",
39− Path: "/user/emails",
41+ Path: "/",
42 if p.Scope == "" {
44 if p.Scope == "" {
@@ -64,8 +66,13 @@ func (p *GitHubProvider) hasOrg(accessToken string) (bool, error) {
64 "limit": {"100"},
66 "limit": {"100"},
69+ endpoint := &url.URL{
67− endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/orgs?" + params.Encode()
70+ Scheme: p.ValidateURL.Scheme,
71+ Host: p.ValidateURL.Host,
72+ Path: path.Join(p.ValidateURL.Path, "/user/orgs"),
73+ RawQuery: params.Encode(),
68− req, _ := http.NewRequest("GET", endpoint, nil)
75+ req, _ := http.NewRequest("GET", endpoint.String(), nil)
69 req.Header.Set("Accept", "application/vnd.github.v3+json")
76 req.Header.Set("Accept", "application/vnd.github.v3+json")
70 resp, err := http.DefaultClient.Do(req)
77 resp, err := http.DefaultClient.Do(req)
71 if err != nil {
78 if err != nil {
@@ -114,8 +121,13 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
114 "limit": {"100"},
121 "limit": {"100"},
124+ endpoint := &url.URL{
117− endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/teams?" + params.Encode()
125+ Scheme: p.ValidateURL.Scheme,
126+ Host: p.ValidateURL.Host,
127+ Path: path.Join(p.ValidateURL.Path, "/user/teams"),
128+ RawQuery: params.Encode(),
118− req, _ := http.NewRequest("GET", endpoint, nil)
130+ req, _ := http.NewRequest("GET", endpoint.String(), nil)
119 req.Header.Set("Accept", "application/vnd.github.v3+json")
131 req.Header.Set("Accept", "application/vnd.github.v3+json")
120 resp, err := http.DefaultClient.Do(req)
132 resp, err := http.DefaultClient.Do(req)
121 if err != nil {
133 if err != nil {
@@ -187,8 +199,14 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) {
187 params := url.Values{
199 params := url.Values{
188 "access_token": {s.AccessToken},
200 "access_token": {s.AccessToken},
190− endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + p.ValidateURL.Path + "?" + params.Encode()
202+
203+ endpoint := &url.URL{
204+ Scheme: p.ValidateURL.Scheme,
205+ Host: p.ValidateURL.Host,
206+ Path: path.Join(p.ValidateURL.Path, "/user/emails"),
207+ RawQuery: params.Encode(),
191− resp, err := http.DefaultClient.Get(endpoint)
209+ resp, err := http.DefaultClient.Get(endpoint.String())
192 if err != nil {
210 if err != nil {
193 return "", err
211 return "", err