Thank you so much for this!!!!

Jun 21, 2012 at 9:59 PM
Edited Jun 21, 2012 at 10:00 PM

After three days of searching around the net, making forum posts and being so baffled as to why this is so difficult, I happened to stumble upon this link 10 minutes before pulling the trigger on no longer using SharePoint Online. It worked! You have no idea how pleased I am.

I just wanted to let you know of a slight modification I made so that I could use this along with the generated classes that come with a Visual Studio Service Reference. As the new Release Preview now has support for OData I was able to add a service reference no problem, a SharePoint Online window opens up and allow me to log in, and it generates the classes required.

So I only ended up using the Login method of your code, and I modified it so I could access the CookieContainer which I then pass into the ServiceContext like so:


TeamSiteDataContext c = new TeamSiteDataContext(new Uri(""));
var spLogin = new SPLogin("");            
var connection = await spLogin.SigninAsync("", "mypass");
c.SendingRequest2 += (sender, eventArgs) => {                                         
(eventArgs.RequestMessage as HttpWebRequestMessage).HttpWebRequest.CookieContainer = connection.CookieContainer;  
var task = Task<IEnumerable<ListTest2Item>>.Factory.FromAsync(c.ListTest2.BeginExecute, c.ListTest2.EndExecute, null);            
var result = await task.ContinueWith(t => {  
if (t.Exception == null)
return t.Result.ToList();
return null;  

Again, thank you so much!!! I may have developed feelings for you:$ lol

Jun 22, 2012 at 1:53 PM

You're welcome!

It's very nice to see that it helped someone :)

I had not much time to continue with this project, I hope to have time in two or three weeks to make a complete example of a metro app with sharepoint... by the way, the project is open for collaborations. :)




Sep 4, 2012 at 12:42 PM


thank you for this code. i took r3ap3r's modifications but I'm getting a fault response from sharepoint with either "The entered and stored passwords do not match." or "This credential is blocked". But the users I'm trying to sign in are working perfectly fine when using Sharepoint Online with a browser. Our company is using Active Directory Sync for users btw. Any idea?