Endpoint to add a repo to an installation?


#1

I found the endpoint to add a repo to an installation in the Installation section of the docs for GitHub Apps. I’m a bit confused with the use case for that endpoint.

At first, I thought that the endpoint was intended for the app, so an authenticated user could add a repo to the installation. Ideally, the app would show a list of repos so the user could add them to the app, something like:

Add repos to MyApp
repo-a ✓
repo-b ✓
repo-c X [ Grant access ]

but then, I don’t know how this could work, as the app doesn’t have access to repo-c (even with user-to-server request).

My next guess was that an OAuth app could make that request on behalf of the user, but in that case, would it make sense to create an OAuth app only so the users can use it to add repos to a different app?

Can I get some clarification around the intended use case for this endpoint? Are my assumptions correct on that an app cannot get a list of repos for which it doesn’t have access, even with user-to-server requests?


#2

:wave: Hey @pnavarrc!

You are correct, an app cannot get a list of repositories it does not have access to. As a rule, user-to-server requests require both the user & the installation have access to an endpoint.

This endpoint is only accessible when authenticating using HTTP Basic Auth or a personal access token and is intended to help with supporting some workflows that were available to OAuth apps (e.g. allow access to all repositories except a few).


#3

Makes sense, thanks @jakewilkins :+1: