0

I am trying to list a user's private github repositories via a github app.

(Note: I am not currently using OAuth, and I am looking for a user's repositories, not an org's.)

I am attempting to make this API call with an installation client, that is, using a client specific to an installation of an app and using a JWT with my private key.

This is the endpoint I am requesting:

https://api.github.com/user/repos?per_page=100&visibility=private

This yields the following response:

{
  "message":"Resource not accessible by integration",
  "documentation_url":"https://docs.github.com/rest/reference/repos#list-repositories-for-the-authenticated-user"
}

The /user/repos not listed in the list of valid app endpoints so I'm not surprised this doesn't work.

Once a user installs my app, how can I list their private repos?

poundifdef
  • 18,726
  • 23
  • 95
  • 134
  • `/user/repo` needs oauth and installation token, and the [docs says you can see private epos](https://docs.github.com/en/rest/reference/repos#list-repositories-for-the-authenticated-user). havent tried myself though, just stumbled upon [this](https://github.community/t/can-github-app-query-private-repos-from-client/13897). – Bagus Tesa Mar 28 '22 at 14:33

1 Answers1

0

The way to do this is by calling the /installation/repositories endpoint. An "installation" might have access to many repos across many users, and this endpoint will encompass them all.

This endpoint is documented here: https://docs.github.com/en/rest/reference/apps#list-repositories-accessible-to-the-app-installation

poundifdef
  • 18,726
  • 23
  • 95
  • 134