I'm using Python3 urllib to try to get a URL for an Artifact using the GitHub API.
The following curl works fine, it (correctly) shows that there is a Location header with the URL I want. There is no response content: only the headers matter:
curl -i -u"$USER:$GH_ACCESS_TOKEN" https://api.github.com/repos/$ORG/$REPO/actions/artifacts/21877858/zip
For the urllib code, auth is working and I get can back JSON responses just fine from other endpoints. But the headers I get back don't include Location
.
opener = get_opener() # bunch of boilerplate
req = request.Request(uri)
# same exact headers as curl sends.
# It doesn't change anything if I change `Accept` to "application/vnd.github.v3+json"
# like GH recommends https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-an-artifact
req.add_header("Accept", "*/*")
# next line doesn't make a difference
req.add_header("User-Agent", "curl/7.64")
with opener.open(req) as response:
print(response.code, response.headers["Location"])
# prints (200, None)
# If I stringify the headers there is a completely different set than
# what curl shows