Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (ClientContext clientContext = new ClientContext("https://site-collection-url"))
- {
- var userName = "admin@tenant.onmicrosoft.com"
- var password = "password";
- SecureString securePassword = new SecureString();
- foreach (char c in password.ToCharArray())
- {
- securePassword.AppendChar(c);
- }
- clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
- clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
- // you can get the Guid of the extension
- // from the [Extension].manifest.json file's id property
- Guid spfxExtension_GlobalHeaderID = new Guid("<Guid of the extension>");
- string spfxExtName = "HelloWorldExtension";
- string spfxExtTitle = "HelloWorld Application Customizer Extension";
- string spfxExtDescription = "Adds HelloWorldExtension to the site";
- string spfxExtLocation = "ClientSideExtension.ApplicationCustomizer";
- string spfxExtProps = ""; // add properties if any, else remove this
- UserCustomAction userCustomAction = clientContext.Site.UserCustomActions.Add();
- userCustomAction.Name = spfxExtName;
- userCustomAction.Title = spfxExtTitle;
- userCustomAction.Description = spfxExtDescription;
- userCustomAction.Location = spfxExtLocation;
- userCustomAction.ClientSideComponentId = spfxExtension_GlobalHeaderID;
- userCustomAction.ClientSideComponentProperties = spfxExtProps;
- clientContext.Site.Context.ExecuteQuery();
- }
Add Comment
Please, Sign In to add comment