Downloading attachments content using OAuth2 from the Confluence

Hi,

There are so many questions so far around the topic “How to download attachments content using OAuth2”. What is surprising, no one gave a definite answer about it, either not answering or giving the obscure one.

So I would like to ask Atlassian’s developers once again. Is there any possibility to download attachments content using OAuth2?

So far it was possible using download link e.g “https://{instance_url}/wiki/download/attachments/{id}/{name}”. Right now it is not possible any more. It only works using Basic Auth.

Error which occurs when trying to download file using download link and OAuth2 access token:
Status Code: 503 Service Temporarily Unavailable

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<meta name="description" content="Encountered a 401 - Unauthorized error while loading this page.">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Atlassian Cloud Notifications - Page access unauthorized</title>
	<link rel="stylesheet" href="/_edge/resources/aui-prototyping.css">
	<style>
		body {
			background: #fff;
		}

		main {
			margin: auto;
			padding-top: 120px;
			text-align: center;
		}

		.suggestion {
			font-size: 16px;
			color: rgb(94, 108, 132);
			width: 350px;
			padding-top: 20px;
			margin: auto;
		}
	</style>
</head>

<body>
	<main>
		<img
        src="/_edge/resources/images/error-generic.svg"
        alt="error icon"
        width="120"
    />
		<h2>
			There was a problem accessing this content
		</h2>
		<p class="suggestion">
			Encountered a 401 - Unauthorized error while loading this page.
		</p>
	</main>
</body>

</html>

Hi @PrzemysawKanach , would this API address your use case? https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-api-content-id-child-attachment-get

1 Like

Hi @JatinChopra,

Thank you for your help.
As far as I know, this endpoint doesn’t allow you to download the attachment.
It only shows some information about the file.

My intention is to download the attachment, not just show details about it.

Cheers.

So the answer is- as of now, we do not support 3LO for downloading images. We are aware of this and are looking into it but have no ETA for the support.

Cheers

1 Like

Thank you, @JatinChopra, for the clear answer.

Do you know the answer why downloading attachment using OAuth2 and download link like “https://{instance_url}/wiki/download/attachments/{id}/{name}” was working and all of a sudden it stopped working? Now there is 503/401 error described in the question.

Cheers.

@PrzemysawKanach good question. It sounds like it might be related to these other auth changes:

Similarly, the instance URL used to work, now only the API gateway works. But I have no idea what caused the change, when it happened, or why.

1 Like

Please refer to this: https://developer.atlassian.com/cloud/confluence/oauth-2-3lo-apps/#3--make-calls-to-the-api-using-the-access-token

1 Like

This is not a problem. I send the request in the right way, but it does not work on the Atlassian side.

curl --location --request GET '<MY_INSTANCE>/rest/api/download/attachments/<ATTACHMENT_ID>/sample.pdf?version=1&modificationDate=1615204617358&cacheVersion=1&api=v2' \
--header 'Authorization: Bearer TOKEN'

Please follow How can i get attachement(img) with oauth? - #4 by JatinChopra
Thanks

1 Like

Thanks to all the input and feedback in threads like this, we have a new option for attachments in OAuth 2:

Great, thank you :slight_smile: