Guest User

Untitled

a guest
Aug 3rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. using (ClientContext clientContext = new ClientContext("https://site-collection-url"))
  2. {
  3. var userName = "admin@tenant.onmicrosoft.com"
  4. var password = "password";
  5. SecureString securePassword = new SecureString();
  6. foreach (char c in password.ToCharArray())
  7. {
  8. securePassword.AppendChar(c);
  9. }
  10.  
  11. clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
  12. clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
  13.  
  14. // you can get the Guid of the extension
  15. // from the [Extension].manifest.json file's id property
  16.  
  17. Guid spfxExtension_GlobalHeaderID = new Guid("<Guid of the extension>");
  18. string spfxExtName = "HelloWorldExtension";
  19. string spfxExtTitle = "HelloWorld Application Customizer Extension";
  20.  
  21. string spfxExtDescription = "Adds HelloWorldExtension to the site";
  22. string spfxExtLocation = "ClientSideExtension.ApplicationCustomizer";
  23. string spfxExtProps = ""; // add properties if any, else remove this
  24.  
  25. UserCustomAction userCustomAction = clientContext.Site.UserCustomActions.Add();
  26. userCustomAction.Name = spfxExtName;
  27. userCustomAction.Title = spfxExtTitle;
  28. userCustomAction.Description = spfxExtDescription;
  29. userCustomAction.Location = spfxExtLocation;
  30. userCustomAction.ClientSideComponentId = spfxExtension_GlobalHeaderID;
  31. userCustomAction.ClientSideComponentProperties = spfxExtProps;
  32.  
  33. clientContext.Site.Context.ExecuteQuery();
  34. }
Add Comment
Please, Sign In to add comment