Confluence download attachments with OAuth 3LO REST API

Hi,

I’m trying to figure out how to download attachment with OAuth.
First i’m getting attachment’s meta using
https://api.atlassian.com/ex/confluence/{siteId}/rest/api/content/att123456

As result i’ve got links, including download link

    "context": "/wiki",
    "self": "https://{url}/wiki/rest/api/content/att123456",
    "download": "/download/attachments/12345/iPhone%20User%20Guide.pdf?version=1&modificationDate=1603884930603&cacheVersion=1&api=v2",
    "collection": "/rest/api/content",
    "webui": "/spaces/{space}/pages/12345/SubPage?preview=%2F32985%2F16678935%2FiPhone+User+Guide.pdf",
    "base": "https://{url}/wiki"
  }

Now i should somehow to build dowload url.
If i’m using same base url, as for other rest calls, like
https://api.atlassian.com/ex/confluence/{siteId}/rest/api/download/attachments/12345/iPhone%20User%20Guide.pdf?version=1&modificationDate=1603884930603&cacheVersion=1&api=v2

it fails with 401 Unauthorized.

If i’m trying to build url like _links.base + _links.download - it fails with 401. It works only with basic auth. But it’s crazy to support both types of auth just for downloads.

Maybe I should add this download postfix to some other base?

1 Like

I am also having this issue. Until just recently, I used https://{org-name}.atlassian.net/wiki/dowload/attachments/...., but it seems that in the last few days, this API was deactivated for OAuth, and the current docs seem to imply that only the cloud_id path is valid now.

The 401 response suggests that an OAuth scope is missing from my application:

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

What scope is needed to download attachments with OAuth?

1 Like

I also encounter this issue.
I do have the scope from access resources API:
readonly:content.attachment:confluence
However I got 401 as well.