Srinivasa Reddy


Hi,
Can you help on this I am trying to get windows contact data using java program and end up with an error 403 Forbidden.
I already get userhandle, DomainAuthenticationToken, RequestApproved information and then trying to open an URL
connection with the uri, https://cumulus.services.live.com/vasreddy@hotmail.co.uk/LiveContacts/

URL u = new URL(uri);
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
uc.setDoOutput(true);
uc.setRequestProperty("Authorization", "DomainAuthToken at=\"" + DomainAuthenticationToken + "\"");
uc.setRequestMethod("GET");

System.out.println("property " + uc.getRequestProperty("Authorization"));
PrintWriter pw = new PrintWriter(uc.getOutputStream());

System.out.println("ResponseCode " + uc.getResponseCode());
System.out.println("ResponseMessage " + uc.getResponseMessage());
System.out.println("getContentType " + uc.getContentType());
System.out.println("getContentLength " + uc.getContentLength());


Then here, I am getting ResponseCode as 403 and ResponseMessage as forbidden.
So please let me know the root cause for this or how to get windows contacts using java




Re: 403: Forbidden' for url: 'https://cumulus.services.live.com/vasreddy@hotmail.co.uk/LiveContacts'

Federico Raggi - MSFT


Hi, Srinivasa!

Windows Live Data uses standard HTTP requests and responses to communicate with applications so the language you use should not be a problem as long as it support creating HTTP requests and getting responses back.

I checked your code, and it seems correct. Here are some basic things that comes to mind:

- Are you sending the HTTP GET request from the same domain, and for the same user The Domnain Authentication Token is specific for each domain and user Live ID.

- The Authorization header should be something like this:

Authorization: DomainAuthToken at="A:20070426T000650Z:really.randomthirdparty.com:AtQDV882yzjy1tl9D5SO1vGM4uxG0U6RAtGRyQiLSyHr0IqPRGXUPQsflp4t8zwKkPRE9lsuNNa7c1BbEn7xQCw9MAH5Ul5+8Y+/LsemCgzWLN9Z4f3E98fXHqw6THofMUgmKc2ob9dBEe0k+nEXwicexxTEnV8eOH+Idm6sE0py5x4lI41zGWGWGFkVz0v2i5HSK7DmRz3qG4LsJKshBsK5DUX/Hrt/G06Y1ublIb5EuYsRZS/vrh+gtGTHkpWTdd1vP3HCg+cJ/a2gCTHZ9EMGSGNBkLrQKURUEzQDVuNs6zK9+91/U6EFRAHdIZJpasNmfVgUnj9z9fYMFFnGWw=="

Note that the above header is a single line.

Let me know if any of this helps. If not, I'll try to create a Java program to see how it works.







Re: 403: Forbidden' for url: 'https://cumulus.services.live.com/vasreddy@hotmail.co.uk/LiveContacts'

Federico Raggi - MSFT

One last thing, could you try without the trailing slash on the uri:

https://cumulus.services.live.com/vasreddy@hotmail.co.uk/LiveContacts

instead of

https://cumulus.services.live.com/vasreddy@hotmail.co.uk/LiveContacts/







Re: 403: Forbidden' for url: 'https://cumulus.services.live.com/vasreddy@hotmail.co.uk/LiveContacts'

Srinivasa Reddy

Hi Federico,

Thank you very much for your timely help. I am able to get contacts information now. There was a problem in my code in preparing authentication token and I commented some of the code related to printwriter as I really don't require PrintWriter(uc.getOutputStream());

but i have added

BufferedReader in = new BufferedReader( new InputStreamReader(uc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}

thanks once again