Is it possible to get PR diff as a GitHub App?

Hello,
When I use OAuth Apps, I can get a git diff of PRs, using application/vnd.github.3.diff accept header, but when I use GitHub App, it says “Resource not accessible by integration”. Is there a way to get this diff?

Thanks!

Hey there @korolvs :wave:

I’m fairly confident the solution here is simple to the marked solution in this post:

Though I’ve seen other users also move away from the .diff in favor of the .patch endpoint which will return your diff.

Curious to know how you go!

If you still have trouble, I’d be curious to know what scope is applied to the key you’re using for the app. The key may simply not have the proper permissions but I bet the solution above from that other thread will get you what you need.

Hey,

It does work for OAuth Apps but doesn’t work for GitHub Apps.

Thanks @korolvs :bow:

Let me see what I can find out about Apps v OAuth and why that Resource not accessible by integration message is coming through.

I’ll do my best to do some research on this and get back with you.

1 Like

Hey again @korolvs !

So after poking around, there are a number of things that could potentially be happening. To that end, I have a few questions, if you don’t mind?

  1. Is your App publicly available? If so, could you link it?
  2. Is the PR you’re trying to query against also public? If so, link?
  3. How are you authenticating your app? (as a GitHub App / as an installation)

Add a repository to an app installation; Check a token; Create a content Get allowed actions for an enterprise; Get GitHub Actions permissions for an For example, to request a pull request as diff format, set the mediaType.format option.

1 Like

You can also swap your head and base branches with the drop-down lists to establish diffs between reference points.

In case anyone else encounters this issue: Check if you granted Read access to “Contents” in GitHub App settings. In my case I didn’t do it and error was happening because my client couldn’t read actual content of a pull request.
Adding it solved the issue.

Yes, we got more than 20,000 installs for our Github app just in one week. We created a push notification alert in our app for repositories. Whenever some repository is updated with new content, we push alerts to our users. This lets users know that there is an update in your repository. We mostly get PR diffs, so we don’t get users to our website. But, we don’t care. Any PR diffs are enough for us because we got users to our site.