diff --git a/applicationset/services/pull_request/github.go b/applicationset/services/pull_request/github.go index 8b962a95716e6..79b128b3b1d1e 100644 --- a/applicationset/services/pull_request/github.go +++ b/applicationset/services/pull_request/github.go @@ -37,7 +37,11 @@ func NewGithubService(token, url, owner, repo string, labels []string, optionalH } } else { var err error - client, err = github.NewClient(httpClient).WithEnterpriseURLs(url, url) + if token == "" { + client, err = github.NewClient(httpClient).WithEnterpriseURLs(url, url) + } else { + client, err = github.NewClient(httpClient).WithAuthToken(token).WithEnterpriseURLs(url, url) + } if err != nil { return nil, err } diff --git a/applicationset/services/scm_provider/github.go b/applicationset/services/scm_provider/github.go index 218daa97bba44..6684269a60313 100644 --- a/applicationset/services/scm_provider/github.go +++ b/applicationset/services/scm_provider/github.go @@ -36,7 +36,11 @@ func NewGithubProvider(organization string, token string, url string, allBranche } } else { var err error - client, err = github.NewClient(httpClient).WithEnterpriseURLs(url, url) + if token == "" { + client, err = github.NewClient(httpClient).WithEnterpriseURLs(url, url) + } else { + client, err = github.NewClient(httpClient).WithAuthToken(token).WithEnterpriseURLs(url, url) + } if err != nil { return nil, err }