Код: Выделить всё
curl -L -H "Authorization: Bearer ghp_XXXX" -o arti.zip \
https://api.github.com/repos/OWNER/REPO/actions/artifacts/ID/zip
< /code>
Следующий код Python выходит из строя, с тем же URL и токеном аутентификации: < /p>
import os, urllib.request
req = urllib.request.Request('https://api.github.com/repos/OWNER/REPO/actions/artifacts/ID/zip')
req.add_header('Authorization', 'Bearer ghp_XXXX')
with urllib.request.urlopen(req) as input:
with open('arti.zip', 'wb') as output:
output.write(input.read())
Код: Выделить всё
urllib.error.HTTPError: HTTP Error 403: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
< /code>
Что не так в коде Python? Тем не менее, Python Doc для request.add_header ()
Подробнее здесь: https://stackoverflow.com/questions/796 ... ed-request