using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Security; using System.Text; using System.Threading.Tasks; using Microsoft.SharePoint.Client; namespace CSOMconnectSPO { class Program { static void Main(string[] args) { string userName = "amos@contoso.onmicrosoft.com"; Console.WriteLine("Enter your password."); SecureString password = GetPassword(); // ClienContext - Get the context for the SharePoint Online Site // SharePoint site URL - https://c986.sharepoint.com using (var clientContext = new ClientContext("https://contoso.sharepoint.com/sites/dev")) { // SharePoint Online Credentials clientContext.Credentials = new SharePointOnlineCredentials(userName, password); // Get the SharePoint web Web web = clientContext.Web; // Load the Web properties clientContext.Load(web); // Execute the query to the server. clientContext.ExecuteQuery(); // Web properties - Display the Title and URL for the web Console.WriteLine("Title: " + web.Title + "; URL: " + web.Url); Console.ReadLine(); } } private static SecureString GetPassword() { ConsoleKeyInfo info; //Get the user's password as a SecureString SecureString securePassword = new SecureString(); do { info = Console.ReadKey(true); if (info.Key != ConsoleKey.Enter) { securePassword.AppendChar(info.KeyChar); } } while (info.Key != ConsoleKey.Enter); return securePassword; } } }