Skip to content

Attachments not downloaded when using scoped API token (401 Unauthorized) #210

Description

@sh1bby

Description

When running the exporter against Confluence Cloud using a scoped API token (Basic Auth), attachments are not downloaded.

The export itself works, but all attachments are skipped with warnings like:

WARNING There is no attachment with title 'image-xxxx.png'. Skipping export.

In the debug output, the underlying request to download the attachment fails with:

401 Unauthorized
{"code":401,"message":"Unauthorized; scope does not match"}

Steps to reproduce:

  1. Configure the exporter to use a Confluence Cloud API token (email + API token)
  2. Run an export on a page containing attachments/images
  3. Observe that attachments are not downloaded

Confluence token configuration:
I used the following scopes:

Manage
manage:confluence-configuration

Read
read:account
read:confluence-content.all
read:confluence-content.permission
read:confluence-content.summary
read:confluence-groups
read:confluence-props
read:confluence-space.summary
read:confluence-user
read:me
readonly:content.attachment:confluence
read:attachment:confluence
read:embed:confluence

Readonly
readonly:content.attachment:confluence

Search
search:confluence

Image

Expected behavior:
Attachments (e.g. images) should be downloaded as part of the export.

Actual behavior:

  • Attachments are skipped
  • 401 errors occur when attempting to download them

Environment:

  • Confluence Cloud
  • Authentication: API token (Basic Auth)
  • Installation: via uvx

Diagnostic info

## Bug Report Diagnostic Info

### Version
confluence-markdown-exporter 4.1.1

### System
Python: 3.14.4 (main, Apr 11 2026, 09:31:02) [GCC 15.2.1 20260209]
Platform: Linux-7.0.2-2-cachyos-x86_64-with-glibc2.43
Architecture: x86_64

### Config
Config file: [redacted]

auth:
  confluence:
    https://******.atlassian.net:
      api_token: '[redacted]'
      cloud_id: '[redacted]'
      pat: ''
      username: '[redacted]'
  jira:
    https://******.atlassian.net:
      api_token: '[redacted]'
      cloud_id: '[redacted]'
      pat: ''
      username: '[redacted]'
connection_config:
  backoff_and_retry: true
  backoff_factor: 2
  max_backoff_retries: 5
  max_backoff_seconds: 60
  max_workers: 20
  retry_status_codes:
  - 413
  - 429
  - 502
  - 503
  - 504
  timeout: 30
  use_v2_api: true
  verify_ssl: true
export:
  attachment_export_all: true
  attachment_href: relative
  attachment_path: '{space_name}/attachments/{attachment_file_id}{attachment_extension}'
  cleanup_stale: true
  enable_jira_enrichment: true
  existence_check_batch_size: 250
  filename_encoding: '"<":"_",">":"_",":":"_","\"":"_","/":"_","\\":"_","|":"_","?":"_","*":"_","\u0000":"_","[":"_","]":"_","''":"_","’":"_","´":"_","`":"_"'
  filename_length: 255
  filename_lowercase: false
  include_document_title: false
  lockfile_name: confluence-lock.json
  log_level: DEBUG
  output_path: '[redacted]'
  page_breadcrumbs: false
  page_href: relative
  page_path: '{space_name}/{homepage_title}/{ancestor_titles}/{page_title}.md'
  page_properties_as_front_matter: true
  skip_unchanged: false

Version

confluence-markdown-exporter 4.1.1

Confluence Version

Confluence Cloud

Jira Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions