Skip to content
This repository was archived by the owner on Oct 25, 2022. It is now read-only.

Commit ac57518

Browse files
committed
Try to authenticate with app via JSON Web Token (JWT).
This failed miserably with a bad credentials error. I tried both with conda-forge PyGithub (1.43.6) and the latest release 1.51 with integrations support: pip install PyGithub['integrations'] Frustratingly there doesn't seem to be a way to specify the extra integrations support in environment.yml. And it's not included in `pip freeze` or `conda env export`. Using PyGithub as a GitHub App is essentially undocumented. I've had to piece together clues from the Issues, Pull Requests, and tests. It says that that part of the API is supported: https://pygithub.readthedocs.io/en/latest/github_objects/Installation.html But I can't figure out how to authenticate. Passing the jwt token from my app to the main class didn't work unfortunately. At some point I'm just going to have to use pyjwt and requests directly. At least that way I can follow the GitHub API documentation instead of playing detective.
1 parent c86c284 commit ac57518

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

github-app.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,13 @@
88
GITHUB_PRIVATE_KEY = os.getenv("GITHUB_PRIVATE_KEY")
99
GITHUB_APP_IDENTIFIER = os.getenv("GITHUB_APP_IDENTIFIER")
1010
GITHUB_WEBHOOK_SECRET = os.getenv("GITHUB_WEBHOOK_SECRET")
11+
12+
app = github.GithubIntegration(
13+
GITHUB_APP_IDENTIFIER,
14+
GITHUB_PRIVATE_KEY,
15+
)
16+
jwt = app.create_jwt()
17+
gh = github.Github(jwt = jwt)
18+
repos = gh.get_repos()
19+
for repo in repos:
20+
print(repo)

0 commit comments

Comments
 (0)