How do I download a patchset from github usings API's

This is for CI/CD setup on multiple gits managed my google repo tool. repo tool looks to be closely tied up with gerrit, we are migrating to github, however would still want to continue with repo tool.

Given a search string is:pr is:open SOME_XX_STRING I need to pull in patchset from from github.

I am using this API Search - GitHub Docs and able to receive the issue response with patchset_url / diff_url.

But from these URLs I am not clear how to proceed further to download the patchset

curl -k ${diff_url} -H "Accept: application/vnd.github.v3.diff"

Is leading to 401 auth error

  "message": "Must authenticate to access this API.",
  "documentation_url": ""

You probably need to send an appropriate authentication token in an Authentication header. You can find information about authentication methods in the “overview” section of the REST API documentation. I notice that the error message you got looks like you might be using GitHub Enterprise, not, so the available methods may be different.

To generate the token @airtower-luna mentioned here is the link to the our documentation to create a personal access token.