Skip to content

List a user's private repositories when authenticated as a GitHub App - #539

Merged
josegonzalez merged 1 commit into
josegonzalez:masterfrom
capehart:app-installation-repositories
Oct 28, 2026
Merged

josegonzalez merged 1 commit into
josegonzalez:masterfrom
capehart:app-installation-repositories

Conversation

@capehart

Copy link
Copy Markdown
Contributor

--as-app skips the /user lookup (installation tokens can't call it), so a user-account backup falls through to /users/{user}/repos. That endpoint only returns public repositories, so --private silently backs up nothing private. The only sign is the warning "Authenticated user is different from user being backed up".

An installation token can list everything the installation can access through GET /installation/repositories, private repositories included. This uses that endpoint for user-account backups with --as-app and unwraps its {"total_count", "repositories"} pages. Org backups keep using /orgs/{org}/repos, and -R still fetches the single repository directly.

Testing

  • tests/test_app_repositories.py: the installation endpoint and page unwrapping, the GHES host, org backups unchanged, -R unchanged. The two listing tests fail without the fix.
  • pytest tests/: 174 passed. flake8 with CI's flags and rst-lint README.rst pass.
  • Live: an App installed on my user account with "All repositories". Before the fix, the run logged the warning above and listed repositories from /users/{user}/repos. After it, the backup included every repository, private ones too.

Independent of #533 and of the private-key work; it applies to pre-minted tokens passed with -t too.

🤖 Generated with Claude Code

With --as-app there is no authenticated user, so a user-account backup
fell through to /users/{user}/repos, which only returns public
repositories. --private silently backed up nothing private.

An installation token can list everything the installation can access
via /installation/repositories, private repositories included. Org
backups keep using /orgs/{org}/repos, and -R still fetches the single
repository directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@josegonzalez
josegonzalez merged commit 7238c5e into josegonzalez:master Oct 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants