public SPService(string username, string password, string url) { using (ClientContext ctx = new ClientContext(url)) { var securePassword = new SecureString(); foreach (char c in password) { securePassword.AppendChar(c); } var onlineCredentials = new SharePointOnlineCredentials(username, securePassword); ctx.Credentials = onlineCredentials; web = ctx.Web; ctx.Load(web); ctx.ExecuteQuery(); //ctx.GetFormDigestDirect().DigestValue var authCookie = onlineCredentials.GetAuthenticationCookie(new Uri(url)); //var fedAuthString = authCookie.TrimStart("SPOIDCRL=".ToCharArray()); webinfo = new WebInfo { Title = web.Title, ErrorMessage = "", DigestInfo = authCookie.ToString() }; context = ctx; } }