GraphQL org member query failure on behalf of GitHub App

When querying the GraphQL API on behalf of my GitHub app, I was able to retrieve all members of my organization. However, one of my org members set their email to private (Personal Settings -> Emails -> “Keep my email addresses private”), and now when the app makes the query, not only do I not receive their email, but the entire OrganizationMemberEdge’s User node is returned as null. It still contains the Role, however. When checking my client response for errors, it says “Resource not accessible by integration” for path “organization.membersWithRole.edges.node.email”.

When testing the same query using my personal access token, the User node is still correctly returned, just minus the email.

Hi @jamesdh,

Thank you for being here! The behavior you are seeing is expected as private user email addresses are not exposed to organization owners. It looks like all node’s related to user emails via API v4 GraphQL only displays user’s public email and you would not be able to create a query that would match the view within your organization’s people tab.

There are two options here, you’d need to inform your organization members to specify a public email address at https://github.com/settings/profile for you be able to retrieve this information via the API.
or
If this isn’t an option, I’d suggest creating an OAuth App to view your organization member’s private email addresses. You’d ask each user to authorize the application so that you can view their private email addresses. You’ll also need to make sure you use the user:email scope for the OAuth App.

I hope this helps!

@andreagriffiths11 I think you missed my primary issue, that the entire User node is not returned if the users email is private. Instead it’s simply null. It’s not simply missing just the email. The entire User node object is null.

@andreagriffiths11 if I remove the email attribute from the query, then the remaining User node object is returned correctly.

Similarly, as I said in the original post, if I run the same exact query but using my personal access token, then entire User node object is still returned, but just minus the email (as I would expect).

Pinging you again because it appears you didn’t read my full description. As the API currently stands, I can’t bulk query org members emails because doing so causes the entire User node to be returned as null. Instead I have to query all org members without their email, and then query them individually to try and retrieve their email (if its not private). This is only true when querying as an app integration. It is not the case (and the API behaves correctly) when querying with my personal access token. See my other messages for more details.

Hi @andreagriffiths11,
as you said, we can fetch member’s private email addresses by creating an OAuth App, So could you please tell me how can we do that.