2

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?

  • Don't know if it may be of any use, but have a look at this blog post anyway. Maybe some of the info it provides can prove useful. In case I misinterpreted your requirement, please just ignore my suggestion. – BlueSoul May 27 '15 at 9:37
1

This article, together with associated sample project, should provide you all details for your exact scenario: on how to allow AppOnly calls in a high trust scenario; retrieving the access token via AAD

Performing app-only operations on SharePoint Online through Azure AD

  • it was premature celebration. With the method discussed in the blog post I receive a Token which authenticates me. But i am unable to write to the Term Store. The "Permissions to other applications" seems to be ignored, I can have 0 applications defined and I am able to authenticate and read the Term Store. And if I add "Office 365 SharePoint Online" with application permissions or delegate permissions set i am still unable to write to the Term Store. Do you have any ideas? – Lockyc Jun 2 '15 at 8:24
  • Yes, writing taxonomy isn't supported (yet) with AppOnly policy: officespdev.uservoice.com/forums/224641-general/suggestions/… – Massimo Prota Jun 2 '15 at 10:25
  • Ah, that would be why. Do you know of any other way I can accomplish this? – Lockyc Jun 3 '15 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.