diff --git a/scripts/artifact_fetch.py b/scripts/artifact_fetch.py index ad15837..cb48b48 100644 --- a/scripts/artifact_fetch.py +++ b/scripts/artifact_fetch.py @@ -201,9 +201,17 @@ def alist_download(manifest, max_bytes): if manifest.get("size_bytes") in (None, 0) and data.get("size"): manifest["size_bytes"] = int(data["size"]) download_url = urllib.parse.urljoin(base_url + "/", raw_url.lstrip("/")) + # This AList deployment gates the download route with x-api-token (the + # Authorization header is NOT recognized there): wrong auth yields a 302 + # to the DingTalk login page instead of bytes. try: - return http_get(download_url, {"Authorization": token}, 180, max_bytes) + return http_get(download_url, {"x-api-token": token}, 180, max_bytes) except FetchError as error: + if error.code == "source_auth_required": + try: + return http_get(download_url, {"Authorization": token}, 180, max_bytes) + except FetchError: + raise error if error.code == "redirect": # Same-origin /d/ route 302s to a signed external URL: follow once # WITHOUT the source token (never forward credentials cross-origin).