How to Activate Workflows can use app permissions Feature programmatically using CSOM in SharePoint

We can activate “Workflows can use app permissions” in SharePoint online site using client object model code (csom). We will use C#.net managed object model code (Microsoft.SharePoint.Client.dll).

“Workflows can use app permissions” is site level feature and the feature id for this feature is: “ec918931-c874-4033-bd09-4f36b2e31fef”.

You can check out this MSDN article for know more about the feature id for various out of box features in SharePoint 2013.

If you are new to SharePoint Online workflow development, you can check out my previous workflow tutorials:

Activate workflows can use app permissions using CSOM SharePoint

Below is the full code to activate workflows can use app permissions using csom in SharePoint Online.

public static void ActivateWorkflowFeature(string siteURL)
{
Guid WebFeatureID = Guid.Parse("ec918931-c874-4033-bd09-4f36b2e31fef");
using (ClientContext ctx = new ClientContext(siteURL))
{
ctx.AuthenticationMode = ClientAuthenticationMode.Default;
ctx.Credentials = new SharePointOnlineCredentials(GetSPOAccountName(), GetSPOSecureStringPassword());
var web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();
var webFeatures = ctx.Web.Features;
ctx.Load(webFeatures);
ctx.ExecuteQuery();
webFeatures.Add(WebFeatureID, true, FeatureDefinitionScope.None);
ctx.ExecuteQuery();
}
}
private static SecureString GetSPOSecureStringPassword()
{
try
{
var secureString = new SecureString();
foreach (char c in ConfigurationManager.AppSettings["SPOPassword"])
{
secureString.AppendChar(c);
}
return secureString;
}
catch
{
throw;
}
}
private static string GetSPOAccountName()
{
try
{
return ConfigurationManager.AppSettings["SPOAccount"];
}
catch
{
throw;
}
}

Once you run the above code, it will activate the “Workflows can use app permissions” feature.

Read some SharePoint 2013 csom tutorials:

I hope this will be helpful to you to activate workflows can use app permissions in SharePoint Online Office 365.

>