| 516 | } |
| 517 | |
| 518 | func validateProject(owner, project string, token *auth.Token) (bool, error) { |
| 519 | url := fmt.Sprintf("%s/repos/%s/%s", githubV3Url, owner, project) |
| 520 | |
| 521 | req, err := http.NewRequest("GET", url, nil) |
| 522 | if err != nil { |
| 523 | return false, err |
| 524 | } |
| 525 | |
| 526 | // need the token for private repositories |
| 527 | req.Header.Set("Authorization", fmt.Sprintf("token %s", token.Value)) |
| 528 | |
| 529 | client := &http.Client{ |
| 530 | Timeout: defaultTimeout, |
| 531 | } |
| 532 | |
| 533 | resp, err := client.Do(req) |
| 534 | if err != nil { |
| 535 | return false, err |
| 536 | } |
| 537 | |
| 538 | err = resp.Body.Close() |
| 539 | if err != nil { |
| 540 | return false, err |
| 541 | } |
| 542 | |
| 543 | return resp.StatusCode == http.StatusOK, nil |
| 544 | } |
| 545 | |
| 546 | func getLoginFromToken(token *auth.Token) (string, error) { |
| 547 | ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) |