I want to access some lists to write data into them from a Windows client (or a service).

I tried the following:

using (ClientContext context = new ClientContext("https://myhost.sharepoint.com/"))
    context.Credentials = new NetworkCredential("MyUserName@domain.com", "SuperSecretPassword");
    Site site = context.Site;

The result is a 403 error that suggests I am not allowed to perform such requests.

How is it possible to write, update or delete some data in lists in SharePoint Online (aka Office Cloud / Office 365)?


Use the SharePointOlineCredentials to access your O365 tenant. See example below:

var targetSite = new Uri("https://Your_O365_URL>");
 var login = "<user@tenant>.onmicrosoft.com";
 var password = "<password>";
 var securePassword = new SecureString();
 foreach (char c in password)

var onlineCredentials = new SharePointOnlineCredentials(login, securePassword);

using (ClientContext clientContext = new ClientContext(targetSite))
 clientContext.Credentials = onlineCredentials;
 Web web = clientContext.Web;
 webSite => webSite.Title);



| improve this answer | |
  • Thx works like a charm! :) – Sascha May 26 '14 at 14:55
  • Glad it helped! – Falak Mahmood May 26 '14 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.