The key aspect is using url instead of browser_download_url in the assets JSON response from GitHub, which always works for both public and private repositories (when using a GitHub token). However, the asset URL uses asset IDs instead of asset filenames. Therefore, I also introduced an Asset type that contains both, the Name of the asset and the DownloadURL.
Then, the majority of the changes are refactoring functions to use Asset instances instead of a plain string. In this way, all functions remain with access to the actual asset name regardless of the URL and thus private assets work seamlessly.
I tested this with both public and private repository assets, and with and without using a GitHub token.
I also ran make test and all the defined tests pass OK.
This PR adds support for downloading assets from private repositories in
eget
.I had to do some code improvements to facilitate this feature, which I implemented in separate commits for an easier review:
Bearer
authorization schemeAccept
header inGet()
application/octet-stream
media typeapplication/vnd.github+json
media typeGetRateLimit()
to useGet()
instead of own HTTP requestThe main changes to support assets in private repositories are in the third commit:
The key aspect is using
url
instead ofbrowser_download_url
in the assets JSON response from GitHub, which always works for both public and private repositories (when using a GitHub token). However, the asset URL uses asset IDs instead of asset filenames. Therefore, I also introduced anAsset
type that contains both, the Name of the asset and the DownloadURL.Then, the majority of the changes are refactoring functions to use
Asset
instances instead of a plainstring
. In this way, all functions remain with access to the actual asset name regardless of the URL and thus private assets work seamlessly.I tested this with both public and private repository assets, and with and without using a GitHub token. I also ran
make test
and all the defined tests pass OK.