Thursday, January 7, 2021

How do I pass user credentials SharePoint Online?

  SharePoint 2013 Client Object Model now has a class called SharePointOnlineCredentials

using (ClientContext Ctx = new ClientContext("http://devprasad007-admin.sharepoint.com"))  

{  

    SecureString passWord = new SecureString();

    Ctx.Credentials = new SharePointOnlineCredentials("ramp@devprasad007.onmicrosoft.com", passWord);

    Web web = Ctx.Web;

    Ctx.Load(web);

    Ctx.ExecuteQuery();

    Console.WriteLine(web.Title);

    Console.ReadLine();

No comments:

Post a Comment