Home:ALL Converter>Check if user is a collaborator on a Github Project

Check if user is a collaborator on a Github Project

Ask Time:2015-10-02T03:47:06         Author:Sam Hakim

Json Formatter

I have a rails app and need to check if a specific user is a collaborator on a Github project, and also the list of GitHub projects a specific user can commit to. This is to verify if they can commit to the project (e.g., are admin or have push rights), and to help them pick off the projects they can commit to.

I tried using the rails gem "omniauth-github" with Github API[1], but it appears one needs to be a repo owner to verify a user's collaborator status.

GET /repos/:owner/:repo/collaborators/:username

Can you please recommend how to check if a user is a collaborator on a project using Github API and omniauth-github gem? Ideally, a user would authorize the app to obtain a list of repos where that user is an owner/collaborator, without also requiring the user to authorize the app to make changes (I don't need such powerful privileges).

Thanks

[1] https://developer.github.com/v3/repos/collaborators/#get

Author:Sam Hakim,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/32895684/check-if-user-is-a-collaborator-on-a-github-project
yy