jenkinsci / jenkinsci/github-branch-source-plugin
[JENKINS-65006] Couldn't authenticate with GitHub app ID when app is installed in 2+ organizations
- Dominant language
- Java
- Stars
- 217
- Forks
- 398
- Avg merge
- 30m
- Merged PRs (30d)
- 1
Description
GitHub app authentication was working fine until the app was installed to a second organization. Then as tokens expired Jenkins started throwing errors
java.lang.IllegalArgumentException: Couldn't authenticate with GitHub app ID , has it been installed to your GitHub organisation / user?
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.lambda$generateAppInstallationToken$1(GitHubAppCredentials.java:216)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.generateAppInstallationToken(GitHubAppCredentials.java:216)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.getToken(GitHubAppCredentials.java:269)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.access$300(GitHubAppCredentials.java:47)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials$CredentialsTokenProvider.getEncodedAuthorization(GitHubAppCredentials.java:183)
at org.kohsuke.github.GitHubClient.getEncodedAuthorization(GitHubClient.java:219)
at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.setupConnection(GitHubHttpUrlConnectionClient.java:113)
at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:56)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:394)
at org.kohsuke.github.GitHubClient.getRateLimit(GitHubClient.java:232)
at org.kohsuke.github.GitHubClient.rateLimit(GitHubClient.java:283)
at org.kohsuke.github.GitHubRateLimitChecker.checkRateLimit(GitHubRateLimitChecker.java:122)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:392)
at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:129)
at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:325)
at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1195)
at org.jenkinsci.plugins.github_branch_source.Connector$GitHubConnection.verifyConnection(Connector.java:678)
at org.jenkinsci.plugins.github_branch_source.Connector$GitHubConnection.connect(Connector.java:635)
at org.jenkinsci.plugins.github_branch_source.Connector$GitHubConnection.access$200(Connector.java:589)
at org.jenkinsci.plugins.github_branch_source.Connector.connect(Connector.java:361)
at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieveActions(GitHubSCMSource.java:1880)
at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:848)
at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:598)
at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278)
at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
---
Originally reported by
csanchez, imported from: Couldn't authenticate with GitHub app ID when app is installed in 2+ organizations
Raw content of original issue
GitHub app authentication was working fine until the app was installed to a second organization. Then as tokens expired Jenkins started throwing errors
java.lang.IllegalArgumentException: Couldn't authenticate with GitHub app ID <REDACTED>, has it been installed to your GitHub organisation / user?
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.lambda$generateAppInstallationToken$1(GitHubAppCredentials.java:216)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.generateAppInstallationToken(GitHubAppCredentials.java:216)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.getToken(GitHubAppCredentials.java:269)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials.access$300(GitHubAppCredentials.java:47)
at org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials$CredentialsTokenProvider.getEncodedAuthorization(GitHubAppCredentials.java:183)
at org.kohsuke.github.GitHubClient.getEncodedAuthorization(GitHubClient.java:219)
at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.setupConnection(GitHubHttpUrlConnectionClient.java:113)
at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:56)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:394)
at org.kohsuke.github.GitHubClient.getRateLimit(GitHubClient.java:232)
at org.kohsuke.github.GitHubClient.rateLimit(GitHubClient.java:283)
at org.kohsuke.github.GitHubRateLimitChecker.checkRateLimit(GitHubRateLimitChecker.java:122)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:392)
at org.kohsuke.github.GitHubClient.fetch(GitHubClient.java:129)
at org.kohsuke.github.GitHubClient.checkApiUrlValidity(GitHubClient.java:325)
at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:1195)
at org.jenkinsci.plugins.github_branch_source.Connector$GitHubConnection.verifyConnection(Connector.java:678)
at org.jenkinsci.plugins.github_branch_source.Connector$GitHubConnection.connect(Connector.java:635)
at org.jenkinsci.plugins.github_branch_source.Connector$GitHubConnection.access$200(Connector.java:589)
at org.jenkinsci.plugins.github_branch_source.Connector.connect(Connector.java:361)
at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieveActions(GitHubSCMSource.java:1880)
at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:848)
at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:598)
at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278)
at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
environment
```
GitHub Enterprise 2.22.6
github-branch-source-plugin 2.10.2 and 8093b3d
```
1 attachment
- [screenshot-1.png](https://issues.jenkins.io/secure/attachment/54108/screenshot-1.png)
> 
Contributor guide
Assessment
This issue has not been assessed yet.