Unable to download exported space from Confluence 2.7.3 - HTTP 403 error.

Vikas Khengare June 30, 2011

Hi

I am using confluence 2.7.3 and able to export space as type HTML by programatically in client app (XML-RPC).

Now I want to download the exported zip file which is on server programatically. I am using HTTP basic authentication mechanism to make connection and download the zip file but it seems not working.

URL dnUrl = new URL(downloadFileUrl);
URLConnection connection = dnUrl.openConnection();
byte[] encoded = Base64.encodeBase64((userName+":"+password).getBytes());
connection.setRequestProperty ("Authorization", "Basic "+new String(encoded));

It is throwing HTTP 403 exception.

Same code is working fine with Confluence 3.5 to download exported zip file.

Can someone tell me how to do basic authentication with Confluence 2.7.3?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2011

Have you tried appending the "os_authType=basic" query parameter to the URL to ensure that Confluence accepts the basic auth header?

0 votes
Vikas Khengare June 30, 2011

Hi Joseph,

You are right

We have to append the "os_authType=basic" as query parameter to downloadable URL.

So final code will look like

downloadFileUrl += "?os_authType=basic"
URL dnUrl = new URL(downloadFileUrl);
URLConnection connection = dnUrl.openConnection();
byte[] encoded = Base64.encodeBase64((userName+":"+password).getBytes());
connection.setRequestProperty ("Authorization", "Basic "+new String(encoded));

Thanks for your help.

0 votes
Vikas Khengare June 30, 2011

After digging for a while I found, If we set cookie 'crowd.token_value' then we can do SSO and open URLConnection with downloadURL to download the exported zip file.

I just copied the cookie value from Browser and inserted in my java program to test. It works fine with Confluence 2.7.3.

But now question is How to get the value for cookie 'crowd.token_value'? It's encrypted value, don't know how confluence is setting in Browser.

Help!

TAGS
AUG Leaders

Atlassian Community Events