Find Questions…

Close ×
First time here? Check out the FAQ!

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

Vikas Khengare asked this question · 66 karma ·

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?

298 views

Vikas Khengare · 66 karma ·

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!

2 Answers:

Joseph Clark [Atlassian] · 21,955 karma ·

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

Vikas Khengare · 66 karma ·

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.

Looking for something else?

Find Questions…

or Browse other questions tagged:

or Ask a Question