mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2026-01-14 18:12:40 +01:00
Fix fine-grained PAT attachment downloads for private repos (#477)
Fine-grained personal access tokens cannot download attachments from private repositories directly due to a GitHub platform limitation. This adds a workaround for image attachments (/assets/ URLs) using GitHub's Markdown API to convert URLs to JWT-signed URLs that can be downloaded without authentication. Changes: - Add get_jwt_signed_url_via_markdown_api() function - Detect fine-grained token + private repo + /assets/ URL upfront - Use JWT workaround for those cases, mark success with jwt_workaround flag - Skip download with skipped_at when workaround fails - Add startup warning when using --attachments with fine-grained tokens - Document limitation in README (file attachments still fail) - Add 6 unit tests for JWT workaround logic
This commit is contained in:
@@ -46,6 +46,16 @@ def main():
|
||||
"Use -t/--token or -f/--token-fine to authenticate."
|
||||
)
|
||||
|
||||
# Issue #477: Fine-grained PATs cannot download all attachment types from
|
||||
# private repos. Image attachments will be retried via Markdown API workaround.
|
||||
if args.include_attachments and args.token_fine:
|
||||
logger.warning(
|
||||
"Using --attachments with fine-grained token. Due to GitHub platform "
|
||||
"limitations, file attachments (PDFs, etc.) from private repos may fail. "
|
||||
"Image attachments will be retried via workaround. For full attachment "
|
||||
"support, use --token-classic instead."
|
||||
)
|
||||
|
||||
if args.quiet:
|
||||
logger.setLevel(logging.WARNING)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user