Add first party support for Github App
- Dominant language
- Go
- Stars
- 11.3k
- Forks
- 2.5k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 49
Description
Many of the apis requires to be invoked as Github App, eg. https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28. And currently we need to use third-party packages like [ghinstallation](https://github.com/bradleyfalzon/ghinstallation) to do so.
However, this is not the full story. When creating a Github App, it involves many different kinds of creds:
- [as Github App itself](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app)
- [as Github App installation](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation)
- [as Github App user](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-with-a-github-app-on-behalf-of-a-user)
And we need to use different cred to call different APIs. For now, the only way to do so is to create many different `github.Client`s, each holding a different credential.
And we need to do this with extra care, as all these token are short-lived, and need to be cached/refreshed periodically. Which means, blindly creating those clients will cause lots of rate limiting issues.
For instance, to use `github.ChecksService`, we need:
- Auth as Github App itself by creating a JWT with app's private key, to call `github.AppServiceCreateInstallationToken`
- Once we have the token, we can auth as app installation, then calling `github.ChecksService`
Which requires 2 `github.Client`s in total.
Contributor guide
Assessment
This issue has not been assessed yet.