If you have seen Pablo Castro's MIX Session about accessing the Windows Live Services via Atom Publishing Protocol and want to play yourself with the protocol, I've built a quick and dirty WinForms app, which logs you in with your Windows Live ID and allows you to edit the request uri.
It doesn't use the Windows Live Client SDK, but uses a Rps ticket, which we get via SOAP request.
You should first add the photo module to your spaces account (http://spaces.live.com)
Afterwards you can connect with your Windows Live ID and password and examine your space...
Download the sample application here:
Be aware that the sample application writes to C:\Temp and does not delete the downloaded information - so do yourself if you use the app on a different computer.
Background information:
The challenging part is more or less how to get authenticated within the winforms application. Most of the samples and documentation uses the delegated authentication model, which can only be used by webapplications.
For this browser I've used the TicketAcquirer class, which I found on MSDN Forums. At least I've found several versions, some working, some not. This one works, and I've slightly modificated it, so that you can pass your username and password along.
FYI: If you are behind a proxy you might want to add a new instance of a WebProxy class to the request...
public class TicketAcquirer
{
private const string applicationId = "10";
private string soapEnvelope = @"<s:Envelope
xmlns:s = ""http://www.w3.org/2003/05/soap-envelope""
xmlns:wsse = ""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd""
xmlns:saml = ""urn:oasis:names:tc:SAML:1.0:assertion""
xmlns:wsp = ""http://schemas.xmlsoap.org/ws/2004/09/policy""
xmlns:wsu = ""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd""
xmlns:wsa = ""http://www.w3.org/2005/08/addressing""
xmlns:wssc = ""http://schemas.xmlsoap.org/ws/2005/02/sc""
xmlns:wst = ""http://schemas.xmlsoap.org/ws/2005/02/trust"">
<s:Header>
<wlid:ClientInfo xmlns:wlid = ""http://schemas.microsoft.com/wlid"">
<wlid:ApplicationID>{0}</wlid:ApplicationID>
</wlid:ClientInfo>
<wsa:Action s:mustUnderstand = ""1"">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</wsa:Action>
<wsa:To s:mustUnderstand = ""1"">https://dev.login.live.com/wstlogin.srf</wsa:To>
<wsse:Security>
<wsse:UsernameToken wsu:Id = ""user"">
<wsse:Username>{1}</wsse:Username>
<wsse:Password>{2}</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</s:Header>
<s:Body>
<wst:RequestSecurityToken Id = ""RST0"">
<wst:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</wst:RequestType>
<wsp:AppliesTo>
<wsa:EndpointReference>
<wsa:Address>http://live.com</wsa:Address>
</wsa:EndpointReference>
</wsp:AppliesTo>
<wsp:PolicyReference URI = ""MBI""></wsp:PolicyReference>
</wst:RequestSecurityToken>
</s:Body>
</s:Envelope>";
public string GetTicket(string username, string password)
{
soapEnvelope = String.Format(soapEnvelope, "10", username, password);
const string url = @"https://dev.login.live.com/wstlogin.srf";
WebRequest request = WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/soap+xml; charset=UTF-8";
request.Timeout = 10 * 1000;
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(soapEnvelope);
request.GetRequestStream().Write(bytes, 0, bytes.Length);
request.GetRequestStream().Close();
WebResponse response;
response = request.GetResponse();
string xml;
using (System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()))
xml = reader.ReadToEnd();
response.Close();
XmlDocument document = new XmlDocument();
document.LoadXml(xml);
XmlNamespaceManager nsManager = new XmlNamespaceManager(document.NameTable);
nsManager.AddNamespace("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
XmlNode node = document.SelectSingleNode(@"//wsse:BinarySecurityToken/text()", nsManager);
if (node == null)
return null;
else
return node.Value;
}
}
The usage of the class is really simple:
TicketAcquirer ta = new TicketAcquirer();
ticket = ta.GetTicket(txtUsername.Text, txtPassword.Text);
We can use the ticket in further requests:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Headers.Add("Authorization", "WLID1.0 t=\"" + ticket + "\"");
request.AllowAutoRedirect = false;
request.UserAgent = "AtomPub Sample";
request.ContentType = "text/xml";
request.Pipelined = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "GET";
Review the documentation at samples and documentation and play yourself.. 