question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some "GHAppInstallation" methods need an installation token, not a JWT token

See original GitHub issue

I can explain the oddity on lines 84-87, since I originally wrote them.

https://github.com/hub4j/github-api/blob/7c8a7ff26ebfb31aed3bfdd8f0825ea56142ba4e/src/test/java/org/kohsuke/github/AbstractGHAppInstallationTest.java#L71-L87

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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
gsmetcommented, Sep 21, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

github-api/GHAppInstallation.java at main
This method will be removed. You should instead use an installation client (with an. * installation token, not a JWT), retrieve a {@link ......
Read more >
Why is my access token not a JWT? (Opaque Token)
Answer: An access token will be issued in one of the following formats: JSON Web Token (JWT) : Tokens that conform to the...
Read more >
JSON Web Token Introduction - jwt.io
Here are some scenarios where JSON Web Tokens are useful: Authorization: This is the most common scenario for using JWT. Once the user...
Read more >
The Ultimate Guide to handling JWTs on frontend clients ...
JWTs (JSON Web Token, pronounced 'jot') are becoming a popular way of handling auth. This post aims to demystify what a JWT is,...
Read more >
How do I create an App Installation Token?
In order to authenticate to GitHub as an installation of your GitHub ... withJwtToken(jwtToken).build(); GHAppInstallation appInstallation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found