Some "GHAppInstallation" methods need an installation token, not a JWT token
See original GitHub issueI can explain the oddity on lines 84-87, since I originally wrote them.
The GitHub
client constructed on line 71 is using the JWT token. Which is appropriate for e.g. retrieving a list of installations for the app and other high-level information about the App.
The tests in GHAppInstallationTest.java
are using API methods that need a client authenticated as an “Installation”, not an “App” though. I.e. a GitHub client needs to be constructed with the “installation token”, which is separate and is retrieved using the “JWT token”.
Details from the documentation:
So the commented out code did exactly that - used the client with the “JWT token” to create an “installation token” and inserted it back on the GHAppInstallation
object, so further API calls would correctly use the “installation token”.
I am pretty sure the live tests will fail now with that code commented out.
And I remember not finding a really nice way (without using setRoot()
) of exchanging those tokens on the GHAppInstallation
object, so it is probably an improvement opportunity.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:17 (8 by maintainers)
Top GitHub Comments
@bitwiseman @yrodiere is working with me at Red Hat on Quarkus GitHub App so I will add him to the test org so he can create tests for his PR.
Related: https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java