Icon
Maintenance Notice: answers.atlassian.com will undergo maintenance from 13:00 - 17:00 UTC on 4 September 2015. During this maintenance window, the service will be offline.
 
1
0
-1

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?

  1. vikas.khengare

    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!

CommentAdd your comment...

2 answers

  1.  
    3
    2
    1

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

      CommentAdd your comment...
    1.  
      1
      0
      -1

      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.

        CommentAdd your comment...