Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 2
Message 1 of 2

GitHub API Collaborators, anyway to list users with direct access a Repository?

Solved! Go to Solution.

With GitHubs API is there anyway to view users with direct access to the repository and exclude the users that are listed under teams?  For example if you use the ui to view a repo, goto settings, manage access, We have an admin team, but also have a user with direct admin access on the repository.  When i use the api:

https://developer.github.com/v3/repos/collaborators/

List Collaborators

GET /repos/:owner/:repo/collaborators

It will provide a response back with every user that has access to that repository including users under teams with permission to the repository.  If user phil is already in the admin team, and then has also been added under manage access as a user with access to the repo with the role admin, he only shows once when the response is viewed from List Collaborators(it doesn't list that he has permission under team admin and also as a user directly added with the admin role to the repository, just that he has admin permissions).

{
	"login": "phil",
	"id": 11111111phil1111,
	"node_id": "XXXXXXXXXXXX",
	"avatar_url": "https://",
	"gravatar_id": "",
	"url": "https://api.github.com/users/phil",
	"html_url": "https://github.com/phil",
	"followers_url": "https://api.github.com/users/phil/followers",
	"following_url": "https://api.github.com/users/phil/following{/other_user}",
	"gists_url": "https://api.github.com/users/phil/gists{/gist_id}",
	"starred_url": "https://api.github.com/users/phil/starred{/owner}{/repo}",
	"subscriptions_url": "https://api.github.com/users/phil/subscriptions",
	"organizations_url": "https://api.github.com/users/phil/orgs",
	"repos_url": "https://api.github.com/users/phil/repos",
	"events_url": "https://api.github.com/users/phil/events{/privacy}",
	"received_events_url": "https://api.github.com/users/phil/received_events",
	"type": "User",
	"site_admin": false,
	"permissions": {
		"admin": true,
		"push": true,
		"pull": true
	}

 We are trying to clean up our repositories and I want to be able to view the user with permissions directly on the repositories and don't care about users in the teams.  Is there anyway to do this with the API?  

1 Reply
Highlighted
Solution
Ground Controller Lvl 2
Message 2 of 2

Re: GitHub API Collaborators, anyway to list users with direct access a Repository?

I found the answer to this just adding ?affiliation=direct at the end of the url returns just users with direct access