Contact Us 1-800-596-4880

Microsoft SharePoint Connector 3.10

Anypoint Connector for Microsoft SharePoint (Microsoft SharePoint Connector) integrates with SharePoint 2013, SharePoint Online, and SharePoint Server Subscription Edition through the REST API for cloud and on-premises deployments. You can manage documents and content, access intranet and extranet portals, collaborate across your organization, and search enterprise-wide resources. The connector supports OAuth 2.0 authentication and provides operations for lists, files, folders, and site management.

For compatibility information and fixed issues, see the Microsoft SharePoint Connector Release Notes.

Before You Begin

To use this connector, you must be familiar with:

  • The Microsoft SharePoint API

  • Anypoint Connectors

  • Mule runtime engine (Mule)

  • Elements and global elements in a Mule flow

  • Creating a Mule app using Anypoint Studio or Anypoint Code Builder

Before creating an app, you must have:

  • Credentials to access the Microsoft SharePoint target resource

  • Anypoint Platform

  • Anypoint Studio or Anypoint Code Builder

POM File Information

<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-sharepoint-connector</artifactId>
  <version>x.y.z</version>
  <classifier>mule-plugin</classifier>
</dependency>

Replace x.y.z with the version that corresponds to the connector you are using.

To obtain the most up-to-date pom.xml file information, access the connector in Anypoint Exchange and click Dependency Snippets.

OAuth v2.0 Authorization Code

Configuring the connector to use OAuth v2.0 Authorization Code authentication requires the following information:

  • Site Url: URL for the target SharePoint instance

  • Consumer Key: OAuth consumer key as registered with the service provider

  • Consumer Secret: OAuth consumer secret as registered with the service provider

  • Listener Config: Configuration for the HTTP listener that listens for requests on the access token callback endpoint

  • Callback Path: Path of the access token callback endpoint

  • Authorize Path: Path of the local HTTP endpoint that triggers the OAuth dance

OAuth Client Credentials

For app-only access to SharePoint Online, use certificate-based OAuth client credentials. App-only access runs without a signed-in user.

SharePoint Online doesn’t accept a client secret for this access. Microsoft retired Azure Access Control Service (ACS), the previous app-only model that used a client ID and a client secret. A client secret can return 401 Unauthorized or a token that expires immediately. The OAuth v2.0 authorization code flow depends on a user refresh token, which doesn’t persist reliably for an unattended integration and can fail the same way.

Use a certificate instead. Generate a self-signed certificate pair, upload the public certificate to the Microsoft Entra app registration, and configure the connector with the private key.

Generate a Self-Signed Certificate Pair

Run these OpenSSL commands where you prepare the Mule app. The first command creates a private key and a public certificate. Change 365 if you need a different validity period in days. The second command packages the private key and public certificate into a PKCS12 keystore. When prompted, enter a keystore password.

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout private.key -out public.crt -subj "/CN=SharePointApp"
openssl pkcs12 -export -out sharepoint-keystore.p12 -inkey private.key -in public.crt -name sharepoint

Keep private.key and sharepoint-keystore.p12 private. Upload only public.crt to Microsoft Entra ID.

Upload the Public Certificate

  1. Log in to Microsoft Azure.

  2. Go to Microsoft Entra ID > App registrations and open the app you use for SharePoint, or register a new app.

  3. Select Certificates & secrets > Certificates > Upload certificate.

  4. Upload public.crt.

  5. Copy the application (client) ID and the directory (tenant) ID. You use the client ID in the connector and the tenant ID in the token URL.

  6. Grant the app the SharePoint application permissions it needs, and grant admin consent. A certificate doesn’t authorize the app to call SharePoint by itself.

Configure the Connector with the Private Key

  1. In Anypoint Studio, create a Mule project and add the SharePoint Connector dependency to the pom.xml file.

  2. Copy sharepoint-keystore.p12 into src/main/resources. The keystore already contains the private key, so don’t add private.key to the project.

  3. Create a Microsoft SharePoint global element and select OAuth Client Credentials.

  4. Set these fields:

    • Site Url: URL of the target SharePoint site

    • Client ID: Application (client) ID from the app registration

    • Token URL: Token endpoint for your tenant, for example https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token

    • Scopes: Scope requested for the access token, for example https://{tenant}.sharepoint.com/.default. Replace {tenant} with your SharePoint tenant name. Without this scope, the connector doesn’t get a token, even when the keystore and Microsoft Entra steps are correct.

    • Keystore alias: sharepoint, the name you set with -name in the openssl pkcs12 command

    • Path to keystore: sharepoint-keystore.p12

    • Keystore password: Password you set when you created the keystore

    • Keystore type: PKCS12

    • TLS Context: TLS configuration used when requesting the OAuth token. In Studio, this field appears on the TLS tab. Configure it when a TLS-inspecting proxy or the token endpoint presents a certificate that the JVM default truststore doesn’t trust.

      The connector sends OAuth token requests through the configured proxy (Host, Port, and related proxy fields). The Disable SSL certificate validation field applies to SharePoint API calls only. It doesn’t apply to OAuth token requests. Use TLS Context to trust a proxy or token-endpoint certificate.

  5. Select Test Connection to confirm that Mule can connect to SharePoint.

  6. Select OK.

Okta Authentication

Okta authentication configuration in global element properties window

Configuring the connector to use Okta authentication requires the following information:

  • Okta Domain: The Okta endpoint that accepts the Okta username and password for authentication, for example: your-domain.okta.com

  • Okta Username: Your Okta username, for example: your-email@example.com

  • Okta Password: Your Okta password.

  • Okta API Token: Okta uses a bearer token for API authentication with a sliding scale expiration, for example: http://developer.okta.com/docs/api/getting_started/getting_a_token.html

  • SharePoint Online Embedded Link: The link of your Microsoft Office 365 SharePoint Online application from Okta, for example: https://your-domain.okta.com/home/office365/0oa14mz7f4HAWypdZ1t7/31737

Security Token Authentication

You can use a SAML security token to log in to SharePoint. The following shows how to configure a security token in Studio:

Security token authentication configuration in global element properties window
  • Security token: Enter the corresponding security token.

  • Site URL: Enter the corresponding site URL.

You can obtain a security token by making a POST request to https://login.microsoftonline.com/extSTS.srf with the following XML body:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
      xmlns:a="http://www.w3.org/2005/08/addressing"
      xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <s:Header>
    <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <a:To s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To>
    <o:Security s:mustUnderstand="1"
       xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <o:UsernameToken>
        <o:Username>[username]</o:Username>
        <o:Password>[password]</o:Password>
      </o:UsernameToken>
    </o:Security>
  </s:Header>
  <s:Body>
    <t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
      <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <a:EndpointReference>
          <a:Address>[endpoint]</a:Address>
        </a:EndpointReference>
      </wsp:AppliesTo>
      <t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
      <t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
      <t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
    </t:RequestSecurityToken>
  </s:Body>
</s:Envelope>

The response from the previous request contains the security token between the <wsse:BinarySecurityToken> tags.

About Connector Terminology

  • Actions - Operations that allow side effects, such as data modification, and cannot be further composed to avoid non-deterministic behavior.

  • Complex types - Keyless named structured types consisting of a set of properties. Complex types are commonly used as property values in model entities, or as parameters or return values for operations.

  • Entities - Instances of entity types, for example, an account or an opportunity.

  • Entity sets - Named collections of entities, for example, an account is an entity set containing account entities. An entity’s key uniquely identifies the entity within an entity set.

  • Entity types - Named structured types with a key. Entity types define the named properties and relationships of an entity, and may derive by single inheritance from other entity types.

  • Enumeration types or Enum types - Named primitive types whose values are named constants with underlying integer values.

  • Functions - Operations that do not have side effects and may support further composition, for example, with additional filter operations, functions, or an action.

Connect in Anypoint Studio 7

You can use this connector in Anypoint Studio by first downloading it from Exchange and configuring it as needed.

Add the Connector to Your Studio Project

Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange button in the Studio taskbar or from the Mule Palette.

Add the Connector Using Exchange

  1. In Studio, create a Mule project.

  2. Click the Exchange icon (X) in the upper-left of the Studio task bar.

  3. In Exchange, click Login and supply your Anypoint Platform username and password.

  4. In Exchange, search for "share".

  5. Select the connector and click Add to project.

  6. Follow the prompts to install the connector.

Add the Connector in Studio

  1. In Studio, create a Mule project.

  2. In the Mule Palette view, click (X) Search in Exchange.

  3. In Add Modules to Project, type "share" in the search field.

  4. Click the connector’s name in Available modules.

  5. Click Add.

  6. Click Finish.

Configure Your First Flow

To configure:

  1. In Anypoint Studio, click File > New > Mule Project.

  2. Specify a value for Project Name and click Finish.

  3. Click the Global Elements tab.

  4. Click Create.

  5. Search for "sharepoint".

  6. Click Microsoft SharePoint and click OK.

  7. Choose the Global Type to configure:

    List of connection types
  8. Click Test Connection to ensure the connection works correctly:

    Global element properties window

Create an Anypoint Studio Flow

To create an Anypoint Studio flow:

  1. In Anypoint Studio, click File > New > Mule Project.

  2. Specify a value for Project Name and click Finish.

  3. Search for http and drag an HTTP connector to the canvas.

  4. Search for sharepoint and drag a Microsoft SharePoint connector next to the HTTP connector.

    Studio flow with File Connector
  5. Double-click the HTTP connector and set Host to 0.0.0.0, Port to 8081, and Path to fileAdd.

  6. Click OK.

  7. Double-click the Microsoft SharePoint connector and click the green plus symbol.

  8. From the Connector Configuration list, click the Microsoft SharePoint configuration that was previously created.

  9. From the Operation list, click File Add.

    Set these fields:

    File add operation properties window
    • File server relative URL: The path and file name in SharePoint of where to create the file.

    • File content stream: The content of the file to be created.

Run a Flow

  1. In Package Explorer, right click your project’s name, and click Run As > Mule Application.

  2. Check the console to see when the application starts. You should see messages such as these if no errors occur:

    ************************************************************
    INFO  2019-10-14 22:12:42,003 [main] org.mule.module.launcher.DeploymentDirectoryWatcher:
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    + Mule is up and kicking (every 5000ms)                    +
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    INFO  2019-10-14 22:12:42,006 [main] org.mule.module.launcher.StartupSummaryDeploymentListener:
    **********************************************************
    *  - - + DOMAIN + - -               * - - + STATUS + - - *
    **********************************************************
    * default                           * DEPLOYED           *
    **********************************************************
    
    ************************************************************************
    * - - + APPLICATION + - -   * - - + DOMAIN + - -  * - - + STATUS + - - *
    ************************************************************************
    * myapp                     * default             * DEPLOYED           *
    ************************************************************************

Frequently Asked Questions

  • Which versions of SharePoint are supported by this connector?

    The SharePoint connector supports SharePoint Online on-premises and SharePoint online versions.

  • What authentication schemes are supported by this connector?

    The connector supports OAuth v2.0 authorization code, certificate-based OAuth client credentials, Okta authentication, and security token authentication. For SharePoint Online app-only access, use certificate-based OAuth client credentials. A client secret isn’t supported for that access.

  • What parts of the SharePoint object model are accessible by the connector?

    Specific support for Files and Folders, Lists, ListItems, and Attachments is offered. Additionally, all other entities of the SharePoint API are accessible in JSON form using the ResolveObject and ResolveCollection operations.

  • Are DataSense and DataWeave supported by this connector?

    Yes, all supported entities and entity attributes are exposed to Studio by the connector for use with DataWeave.

  • What operations can I perform with the connector?

    For the Lists and ListItems API, operations include create, retrieve, update, and delete.

    For Files and Folders, operations include add, retrieve content, retrieve metadata, delete, check out, undo check out, check in, publish, unpublish, approve, deny, recycle, and copy.

  • What Mule editions can I use this connector with?

    This connector is supported on any Enterprise Edition Anypoint platform running on any operating system and bit type, including the CloudHub integration PaaS.

  • How do I build a query for a query operation?

    The query operations Folder Query, File Query, and List Item Query only support OData queries.

    For the List Item Query operation, the query has this format: LIST_ID?$select=FIELDS_TO_SELECT&filter=FILTER_PART.

    For example: Vessels?$select=Title,FLAG,SEGMENT,ID,VesselName&$filter=Title eq 1.

    The same format applies to the other query operations.

    To learn more about building queries, see the SharePoint documentation page Use OData query operations in SharePoint REST requests.

  • How do I parse an HTML form so that I can test the demo?

    Use the <parse-template> statement, as shown in the Use Case XML section. In this use case, forminput.html is the file that Mule uses as a template into which to insert values extracted from the message properties or variables. For more information, see the Parse Template Reference.

Use Case XML

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:sharepoint="http://www.mulesoft.org/schema/mule/sharepoint"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
	http://www.mulesoft.org/schema/mule/core/current/mule.xsd
	http://www.mulesoft.org/schema/mule/http
	http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
	http://www.mulesoft.org/schema/mule/sharepoint
	http://www.mulesoft.org/schema/mule/sharepoint/current/mule-sharepoint.xsd
	http://www.mulesoft.org/schema/mule/ee/core
	http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
 <configuration-properties file="mule-app.properties"/>
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
		<http:listener-connection host="localhost" port="8081" />
	</http:listener-config>
	<sharepoint:sharepoint-online-config
		name="SharePoint_SharePoint_online"
		doc:name="SharePoint online">
		<sharepoint:online-connection
			username="${sharepoint.username}"
			password="${sharepoint.password}"
			siteUrl="${sharepoint.siteUrl}"
			disableCnCheck="${sharepoint.disableCnCheck}" />
	</sharepoint:sharepoint-online-config>
	<flow name="UI-PROVIDER">
		<http:listener
			doc:name="Listener"
			config-ref="HTTP_Listener_config"
			path="/demo"/>
		<parse-template doc:name="Parse Template" location="formInput.html"/>
	</flow>
	<flow name="FILE-ADD_FLOW">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config"
		path="/fileadd"/>
		<sharepoint:file-add doc:name="File add"
		config-ref="SharePoint_SharePoint_online"
		fileServerRelativeUrl="#[attributes.queryParams.path]"
		overwrite="true">
		<sharepoint:file-content-stream ><![CDATA[#[attributes.queryParams.content]]]></sharepoint:file-content-stream>
		</sharepoint:file-add>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
payload.name
]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<set-payload value="#[payload ++ ' Successfully created.']"
		doc:name="Set Payload" mimeType="text/plain"/>
	</flow>

	<flow name="FILE-GET-CONTENT-FLOW"  >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config"
		path="/filegetcontent"/>
		<sharepoint:file-get-content doc:name="File get content"
		 config-ref="SharePoint_SharePoint_online">
			<sharepoint:file-server-relative-url ><![CDATA[#[attributes.queryParams.path]]]></sharepoint:file-server-relative-url>
		</sharepoint:file-get-content>
		<set-payload value="#[payload]" doc:name="Set Payload"
		 mimeType="text/plain"/>
	</flow>

	<flow name="FILE-GET-META-FLOW">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/getmetadata"/>
		<sharepoint:get-metadata doc:name="Get metadata"
		 config-ref="SharePoint_SharePoint_online">
			<sharepoint:file-server-relative-url ><![CDATA[#[attributes.queryParams.path]]]></sharepoint:file-server-relative-url>
		</sharepoint:get-metadata>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
	<flow name="FILE-DELETE-FLOW">
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config"
		path="/deletefile"/>
		<sharepoint:file-delete doc:name="File delete"
		 config-ref="SharePoint_SharePoint_online">
			<sharepoint:file-server-relative-url ><![CDATA[#[attributes.queryParams.path]]]></sharepoint:file-server-relative-url>
		</sharepoint:file-delete>
		<set-payload value="#[payload  ++ ' Successfully deleted.']"
		doc:name="Set Payload" mimeType="text/plain"/>
	</flow>
</mule>

See Also