How to get the list of Organizations a user belongs to in GitHub?
github-api
Solution
It should but, as mentioned
- For my account, I don't belong to any organization: https://api.github.com/users/VonC/orgs
- `defunk`, however, is part of public orgs: https://api.github.com/users/defunkt/orgs
Since the list orgs API will only list public memberships, regardless of authentication. (more precisely, `GET /orgs/{org}/memberships/{username}`)
If you need to fetch all of the organization memberships (public and private) for the authenticated user, use the List your organizations API instead.
Maybe your user is not part of any public orgs, only private ones.
More recently, using `gh`, the GitHub CLI after a `gh auth login`:
gh api \
-H "Accept: application/vnd.github+json" \
/user/orgs \
--jq ".[].login"
One line:
gh api -H "Accept: application/vnd.github+json" /user/orgs --jq ".[].login"
Problem
I'm trying to do what the title says, using GitHub's API, I'm trying to get the list of orgs any user belongs to... my problem, is that I can't find a way to do it. According to the API's doc: https://developer.github.com/v3/orgs/ using this endpoint: ``` /users/:user/orgs ``` That should list them, but it's not doing it for my user, so I'm guessing this only lists orgs created by the user. If this is the case, is there a way around it somehow, so I can get the list of organizations that any user belongs to?