rest.js: Cannot download private release asset
I am trying to download an asset from Github. Here is the corresponding code:
import Octokit from "@octokit/rest"
const octokit = new Octokit({
auth: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
});
const owner = "Geode-solutions";
const repo = "opengeode";
const asset_id = 13450175;
octokit
.request("GET /repos/:owner/:repo/releases/assets/:asset_id", {
headers: {
Accept: "application/octet-stream"
},
owner,
repo,
asset_id
});
I got this error in return:
OPTIONS https://github-production-release-asset-2e65be.s3.amazonaws.com/156866568/4524ae80-99ab-11e9-93db-8c3a783c062c?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190702%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190702T120659Z&X-Amz-Expires=300&X-Amz-Signature=65d90d511f7753dde757d77cab65ccea135868dce37c386e6fdb7a52c1ae813e&X-Amz-SignedHeaders=host&actor_id=3213882&response-content-disposition=attachment%3B%20filename%3DOpenGeode-1.5.16-Linux.tar.gz&response-content-type=application%2Foctet-stream 403 (Forbidden)
Access to fetch at 'https://github-production-release-asset-2e65be.s3.amazonaws.com/156866568/4524ae80-99ab-11e9-93db-8c3a783c062c?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190702%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190702T120659Z&X-Amz-Expires=300&X-Amz-Signature=65d90d511f7753dde757d77cab65ccea135868dce37c386e6fdb7a52c1ae813e&X-Amz-SignedHeaders=host&actor_id=3213882&response-content-disposition=attachment%3B%20filename%3DOpenGeode-1.5.16-Linux.tar.gz&response-content-type=application%2Foctet-stream' (redirected from 'https://api.github.com/repos/Geode-solutions/opengeode/releases/assets/13450175') from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
What do I have to add to my headers to make it works? Thanks for your help!
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 9
- Comments: 38 (15 by maintainers)
Don’t expect this to be resolved anytime soon. I will update this issues as soon as there are any news.
Issue-Label Bot is automatically applying the label
bugto this issue, with a confidence of 0.54. Please mark this comment with 👍 or 👎 to give our bot feedback!Links: app homepage, dashboard and code for this bot.
Unfortunately no. The only thing you can do right now is to inform support@github.com that this is a blocking issue for you to bump the priority on the problem internally.
Hi, have you tried with:
The
bodyshould contains the content of your asset.You can do it also with
curl:Here is the magic required to stream release assets to a file using rest.js, typescript, and async/await:
You can also use
to get generic request options (except the
authorizationheader), see https://github.com/octokit/endpoint.js. You can pass the requestOptions to axios or any custom request library.Thanks @edospadoni for the hint!
For now, we have to download assets from private repos via plain HTTP calls outside Octokit. I use got for the HTTP call -
I promise that as soon as there is an update I will post it here. For the time being, the best you can do is to contact support at https://support.github.com/contact and let them know about your use case. They are aware of the problem, but the more people report it and share their use cases, the higher the priority will get.
Thank you all for your patience and support
I’ll bring it up tomorrow in a meeting, I’ll keep you posted here.
Sorry, I’m not aware of any movement on this, unfortunately. Maybe @nickfloyd can check, but as this has been open for so long, I wouldn’t get my hopes up.
@gr2m any update? Github is deprecating the workarround with
access_token: https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parametersLooks like this does not throw an error
but
response.bodyis null. My understanding is thatno-corsmeans you cannot get access to the returned data at all