Search code examples
pythongitgithubpygithub

How to add an outside collaborator to an individual organization repository using PyGithub?


I am writing a python application which uses GitHub using PyGitHub library. I have an organization which contains several private repos. I want to invite two different users and give them read-only access to two different repositories.

I have been looking through PyGitHub documentaiton but there doesn't seem to be a way to add an individual collaborator to a repository without making him a part of the team and giving him access to all repositories in the organization.

https://pygithub.readthedocs.io/en/latest/github_objects/Organization.html

Does anyone know how to do that?


Solution

  • It's no different from any other repository, and is not special for organizations. Get the Repository you're interested in with get_repo() and then use add_to_collaborators().