Created
May 18, 2019 08:52
-
-
Save gautamdsheth/9df7cdfef877f1a5e27cccb4f83eb1c3 to your computer and use it in GitHub Desktop.
Apply OOTB theme via CSOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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