Attempting to use worker to download gh artifact
I am attempting to download a GitHub artifact in a cf worker. I have written the JS and tested in my local environment and it works. However, when I try and run it on the worker playground I get this error.
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidAuthenticationInfo</Code><Message>Authentication information is not given in the correct format. Check the value of Authorization header.
RequestId:fdc12948-501e-00d3-59cf-6b1ea0000000
Time:2024-03-01T11:59:22.1038850Z</Message></Error>
The github auth header has the value of 'Bearer {gh_token}' however it seems that the cf fetch function does not permit there to be a space in the key?2 Replies
What is the code snippet for the fetch call you are running? (Of course don't share the token or other sensitive info, just enough to reproduce)
const owner = "";
const repo = "";
const runsResponseJson = await fetch(
https://api.github.com/repos/${owner}/${repo}/actions/runs?per_page=1&status=success
).then(x => x.json());
const artifactsResponseJson = await fetch(https://api.github.com/repos/${owner}/${repo}/actions/runs/${runsResponseJson.workflow_runs[0].id}/artifacts?name=post_image
).then(x => x.json());
console.log(artifactsResponseJson.artifacts);
const image = await fetch(artifactsResponseJson.artifacts[0].archive_download_url, {
headers: {
"Authorization": "Bearer " + "auth_token"
}
});
anyone?