Getting user organization membership

I have following GraphQL query to retrieve number of organizations where user is member

user(login: "smith") {
  login
  organizations {
    totalCount
  }
}

I’m running it under site-admin api token, but the totalCount number are dependend whether the site-admin account is member/owner of all organizations. When user ‘smith’ is member of organization, where the site-admin account is not member/owner, then this organization is not counted/displayed in the organizations connections.

Please, is this correct? Are there any other ways how to get user’s organization memberships?

Hi @petr-hlavka, Welcome to the community! We are happy you’ve joined us.
That is the expected result for your GraphQL query.

If you need to fetch all the organization memberships (public and private) you can use the List your organizations endpoint instead.

You’ll need to make the request to the Members API’s List your organization memberships endpoint and authenticate that request with an impersonation OAuth token. This will show all organization memberships, both public and hidden. When you’re done, we advise deleting the impersonation OAuth token.

I hope this helps!