I am trying to build a MSSQL 2014 SSIS Package to update our SharePoint Online Term Store using CSOM. The SSIS package operates in the same fashion as a Console Application.
I would like to be able to authenticate with SharePoint via an API Key rather than using a User account and having the credentials within the solution. I have come across a couple of ways of doing this, but it appears that all of the methods have prerequisites like the project being an MVC project or a SharePoint solution. These project types include libraries which seem unavailable to Console Applications.
One method which I had some hope for was creating a Web Application in the Azure AD dashboard and add permissions for SharePoint Online.
After creating the AzureAD application I have tried to use an Authentication token which I collected by using AzureAdAuthentication.cs
from the AzureAD.GroupMembership.Console
example.
ClientContext cc = new ClientContext(@"https://[TENANT].sharepoint.com/");
cc.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(context_ExecutingWebRequest);
static void context_ExecutingWebRequest(object sender, WebRequestEventArgs e) {
e.WebRequestExecutor.WebRequest.Headers["Authorization"] = string.Format("Bearer {0}", AzureAdAuthentication.AcquireApplicationToken());
}
With no luck. Is there a better way of getting the AzureAD token? Or getting the correct token and providing it to SharePoint?
Have I missed something completely obvious?