Skip to content

Instantly share code, notes, and snippets.

@gautamdsheth
Created May 18, 2019 08:52
Show Gist options
  • Select an option

  • Save gautamdsheth/9df7cdfef877f1a5e27cccb4f83eb1c3 to your computer and use it in GitHub Desktop.

Select an option

Save gautamdsheth/9df7cdfef877f1a5e27cccb4f83eb1c3 to your computer and use it in GitHub Desktop.
Apply OOTB theme via CSOM
string userName = "admin@tenant.onmicrosoft.com";
string password = "<your-password>";
string siteUrl = "https://<tenant>.sharepoint.com/sites/testsite/";
using (ClientContext clientContext = new ClientContext(siteUrl))
{
SecureString securePassword = new SecureString();
foreach (char c in password.ToCharArray())
{
securePassword.AppendChar(c);
}
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
ThemeManager.ApplyTheme(clientContext.Web, OfficeDevPnP.Core.Enums.SharePointTheme.Orange);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment