What is the purpose of the "Add repository to installation" endpoint?


#1

I have an app that is installed on certain repositories on my account and also has user permissions for me via oauth. Since I am an admin, I see that there is an API I can use to add the app to further repos:

PUT /user/installations/:installation_id/repositories/:repository_id

However, there is no way to discover IDs of repositories that the app hasn’t been added to, even with an admin user token. Is this intentional? If so, what is a valid use case for this API?


#2

Hi @PranayAgarwal

@PranayAgarwal I’m afraid I’m not sure what type of token you are referring to, is this token on GitHub Dotcom or on a GitHub Enterprise Instance?


#3

Hi @tarebyte, I’m talking about a user token issued via a GitHub App on GitHub Dotcom.

If I call “https://api.github.com/user/repos” using this token, I get

{
    "message": "Resource not accessible by integration",
    "documentation_url": "https://developer.github.com/v3/repos/#list-your-repositories"
}

#4

@PranayAgarwal The documentation for List your repositories doesn’t have the tooltip indicating that it has been enabled for GitHub Apps, so it looks like you’re right that this endpoint isn’t available with a user token generated via a GitHub App.

I’m not actually sure what the plans are for that endpoint. It doesn’t make sense to call it for the app itself, but I do see that it could be useful in the context of a user-to-server call.


#5

@kytrinyx It makes sense that the add repository endpoint shouldn’t be callable by the app itself. Allowing it from a user context is, however, very useful since it makes it easier for apps to provide that option to users without redirecting them to https://github.com/settings/installations/xyz.

What’s missing is repository discoverability. It would be great if the user token could get a minimal repository list scope added by default as well.