@@ -137,36 +137,56 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
137 } `json:"organization"`
137 } `json:"organization"`
140− params := url.Values{
140+ type teamsPage []struct {
141− "limit": {"200"},
141+ Name string `json:"name"`
142+ Slug string `json:"slug"`
144+ Login string `json:"login"`
145+ } `json:"organization"`
144− endpoint := &url.URL{
148+ pn := 1
145− Scheme: p.ValidateURL.Scheme,
149+ for {
146− Host: p.ValidateURL.Host,
150+ params := url.Values{
147− Path: path.Join(p.ValidateURL.Path, "/user/teams"),
151+ "limit": {"200"},
148− RawQuery: params.Encode(),
152+ "page": {strconv.Itoa(pn)},
150− req, _ := http.NewRequest("GET", endpoint.String(), nil)
151− req.Header.Set("Accept", "application/vnd.github.v3+json")
152− req.Header.Set("Authorization", fmt.Sprintf("token %s", accessToken))
153− resp, err := http.DefaultClient.Do(req)
158− body, err := ioutil.ReadAll(resp.Body)
155+ endpoint := &url.URL{
159− resp.Body.Close()
156+ Scheme: p.ValidateURL.Scheme,
160− if err != nil {
157+ Host: p.ValidateURL.Host,
161− return false, err
158+ Path: path.Join(p.ValidateURL.Path, "/user/teams"),
162− }
159+ RawQuery: params.Encode(),
163− if resp.StatusCode != 200 {
164− return false, fmt.Errorf(
165− "got %d from %q %s", resp.StatusCode, endpoint.String(), body)
162+ req, _ := http.NewRequest("GET", endpoint.String(), nil)
163+ req.Header.Set("Accept", "application/vnd.github.v3+json")
164+ req.Header.Set("Authorization", fmt.Sprintf("token %s", accessToken))
165+ resp, err := http.DefaultClient.Do(req)
170+ body, err := ioutil.ReadAll(resp.Body)
175+ if resp.StatusCode != 200 {
176+ return false, fmt.Errorf(
177+ "got %d from %q %s", resp.StatusCode, endpoint.String(), body)
168− if err := json.Unmarshal(body, &teams); err != nil {
181+ if err := json.Unmarshal(body, &tp); err != nil {
169− return false, fmt.Errorf("%s unmarshaling %s", err, body)
182+ return false, fmt.Errorf("%s unmarshaling %s", err, body)
188+ teams = append(teams, tp...)
172 var hasOrg bool
192 var hasOrg bool