From 4697461fb184ef8dd1a3d7e201fd0e4d00868cbf Mon Sep 17 00:00:00 2001 From: reggie-k Date: Mon, 21 Apr 2025 17:33:40 +0300 Subject: [PATCH] pr and scm generators auth use token correctly Signed-off-by: reggie-k --- applicationset/services/pull_request/github.go | 6 +++++- applicationset/services/scm_provider/github.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/applicationset/services/pull_request/github.go b/applicationset/services/pull_request/github.go index a69f5a967c6da..861dd68e87502 100644 --- a/applicationset/services/pull_request/github.go +++ b/applicationset/services/pull_request/github.go @@ -26,7 +26,11 @@ func NewGithubService(token, url, owner, repo string, labels []string) (PullRequ httpClient := &http.Client{} var client *github.Client if url == "" { - client = github.NewClient(httpClient).WithAuthToken(token) + if token == "" { + client = github.NewClient(httpClient) + } else { + client = github.NewClient(httpClient).WithAuthToken(token) + } } else { var err error client, err = github.NewClient(httpClient).WithEnterpriseURLs(url, url) diff --git a/applicationset/services/scm_provider/github.go b/applicationset/services/scm_provider/github.go index 489940ad2b083..bf33b16d4e8ee 100644 --- a/applicationset/services/scm_provider/github.go +++ b/applicationset/services/scm_provider/github.go @@ -25,7 +25,11 @@ func NewGithubProvider(organization string, token string, url string, allBranche httpClient := &http.Client{} var client *github.Client if url == "" { - client = github.NewClient(httpClient).WithAuthToken(token) + if token == "" { + client = github.NewClient(httpClient) + } else { + client = github.NewClient(httpClient).WithAuthToken(token) + } } else { var err error client, err = github.NewClient(httpClient).WithEnterpriseURLs(url, url)