Authenticating in Office 365

Code Samples, Office 365, SharePoint

The following SharePoint 2013 code will connect to Office 365 and load the Web properties using CSOM:

ClientContext spctxt = new ClientContext(url);
SharePointOnlineCredentials cred = new SharePointOnlineCredentials(username, SecureStringFromString(password));
spctxt.Credentials = cred;
spctxt.Load(spctxt.Web);
spctxt.ExecuteQuery();

For both 2013 and 2010 versions, you need the code from Wiktor Wilen’s post: http://www.wictorwilen.se/Post/How-to-do-active-authentication-to-Office-365-and-SharePoint-Online.aspx

 

 

What do you think?