Github app auth for Graphql apis #190797
Replies: 1 comment 1 reply
-
|
Hi @utkarsha-ubale-sp , The issue you're encountering is likely due to the change in authentication context. When using a PAT, the viewer is you, but when using a GitHub App, the viewer is the App's bot account. Since the bot isn't a member of the organization, it cannot "see" members through the same relational paths. To resolve this, you need to query the Organization directly and ensure your App has the correct Permissions. 1. Update GraphQL QueryInstead of starting with the user or viewer node, query the organization node and use membersWithRole. This is the most reliable way for a GitHub App to fetch a list of members. 2. Verify GitHub App PermissionsA GitHub App doesn't inherit your permissions; it only has what you explicitly grant it. For the query above to work, go to your App settings: Settings > Developer Settings > GitHub Apps > [Your App] Permissions & events > Organization permissions Set Members to Read-only. Important: If you update permissions, the Organization owner must accept the new permissions on the installation for them to take effect. 3. Implementation with Octokit (@octokit/auth-app)Since you are using TypeScript and Octokit, ensure you are using the getInstallationOctokit method. A common mistake is using the App-level JWT instead of an Installation Access Token. I hope this helps get your integration back on track! If you found this helpful, please consider marking it as the Answer so others in the community can find it easily 👍 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Question
💬 Feature/Topic Area
API
Body
was using PAT for authentication and below GraphQL query to fetch details of org member. Now, I want to support auth via github apps as well, but this query doesn't provide the expected response. what is the correct query to fetch org members with github app authentication. I am using Ocktokit in ts for generating token
and
Beta Was this translation helpful? Give feedback.
All reactions