> For the complete documentation index, see [llms.txt](https://docs.datasaur.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasaur.ai/integrations/external-object-storage/microsoft-sharepoint.md).

# Microsoft SharePoint

Connect a SharePoint document library to Datasaur. Once connected, you can attach the library to a knowledge base, which keeps its documents in sync on a schedule you set.

{% hint style="info" %}
**SharePoint** external object storage is currently available only for [LLM Labs](https://app.notion.com/llm-projects/llm-introduction.md).
{% endhint %}

## Prerequisites

* A Microsoft Entra ID (Azure AD) tenant containing the SharePoint site.
* Permission to register an application in that tenant, or an admin who can do it for you.
* Access to the site with the Microsoft account you will sign in with.

## Setup

#### Step 1 — Register an Application

<figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-2acdfe6fa2c51d0f3e8cabfa7a4fb7bf803f02f2%2Fimage%20(60).png?alt=media" alt=""><figcaption></figcaption></figure>

1. Open the [Azure Portal](https://portal.azure.com/) and go to **Microsoft Entra ID**.
2. Select **App registrations**, then click **New registration**.
3. Enter a **Name**, for example `Datasaur SharePoint`.
4. Under **Supported account types**, keep the default single-tenant option unless users from other tenants need to connect.
5. Under **Redirect URI**, select **Web** and enter:

   ```
   https://<your-datasaur-host>/api/eos/authorization/sharepoint
   ```

   On Datasaur Cloud, use `https://llm.datasaur.ai/api/eos/authorization/sharepoint`. Self-hosted deployments must be served over HTTPS.
6. Click **Register**.
7. From the **Overview** blade, copy the **Application (client) ID** and the **Directory (tenant) ID**.

#### Step 2 — Add API Permissions

<figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-3322740e242250c07995bef54d0e448fc897eec4%2Fimage%20(61).png?alt=media" alt=""><figcaption></figcaption></figure>

1. Go to **API permissions** and click **Add a permission**.
2. Select **Microsoft Graph**, then **Delegated permissions**.
3. Add `Files.Read.All` and `Sites.Read.All`, then click **Add permissions**.
4. If your tenant requires it, click **Grant admin consent** and confirm. After admin consent is granted, a white check mark with green background should appear in the status column.

Datasaur also requests `openid`, `profile`, and `offline_access`. You do not need to add these.

#### Step 3 — Create a Client Secret

<figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-db5f48f5c95e04857bfe400cc2c1245e356f7d77%2Fimage%20(62).png?alt=media" alt=""><figcaption></figcaption></figure>

1. Go to **Certificates & secrets** and click **New client secret**.
2. Enter a description, choose an expiry, and click **Add**.
3. Copy the secret's **Value** (not the Secret ID).

{% hint style="warning" %}
The **Value** is shown only once. Note the expiry date too: when the secret expires, the connection stops syncing.
{% endhint %}

#### Step 4 — Find Your Site Path and Library Name

Open the site in your browser and look at the URL:

```
<https://contoso.sharepoint.com/sites/marketing/Shared%20Documents/Forms/AllItems.aspx>
```

* **Site path** — The part identifying the site, here `/sites/marketing`. Leave empty to use the root site.
* **Document library name** — The library's name in the left navigation, such as `Documents`. Leave empty to use the default library. Matching ignores case.

#### Step 5 — Connect SharePoint in LLM Labs

1. Go to **Settings > External object storage** and click **Add external object storage**.
2. Select **SharePoint**.
3. Fill in the form:

   | Field                            | Required                    | Notes                               |
   | -------------------------------- | --------------------------- | ----------------------------------- |
   | Azure AD Application (client) ID | Yes                         | From Step 1.                        |
   | Client secret                    | Yes, for a Web registration | From Step 3.                        |
   | Tenant ID                        | Only for single-tenant apps | From Step 1.                        |
   | Site path                        | No                          | Blank connects the root site.       |
   | Document library name            | No                          | Blank connects the default library. |
4. Click **Authorize.**
5. Sign in with an account that can access the site and click **Accept** on the consent screen.\
   ![](https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-f36731bd85c6d56fc299c5d4fa58058fe7e5371c%2Fimage%20\(64\).png?alt=media)
6. You return to Datasaur. The connection appears in the list as `{Site} - {Library}`, for example `Marketing - Documents`.<br>

   <figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-39496268aa92a7bf74b39ba01eb371b03e35a3a6%2Fimage%20(65).png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Datasaur shows the consent screen every time you authorize, not only the first time.
{% endhint %}

## Using the Connection

1. Open a knowledge base, choose **Connect object storage...**, and pick your SharePoint connection.<br>

   <div align="left"><figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-0a60afbd768b36486d05b13aafdb8615bd2eac96%2Fimage%20(66).png?alt=media" alt=""><figcaption></figcaption></figure></div>

   <div align="left"><figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-253955a78841faa86ef13a1be415e8759a93d4be%2Fimage%20(68).png?alt=media" alt=""><figcaption></figcaption></figure></div>
2. Set the sync rules and schedule, then click Connect object storage.\
   ![](https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-f44b2f4d08fc5ebb3cf6bbc57d45dad5fd08c71a%2Fimage%20\(69\).png?alt=media)

The connection syncs the whole library by those rules. It is not a file-by-file picker. To change the rules later, use **Edit rules or schedule...** on the connected source, available once the knowledge base has been updated.<br>

<figure><img src="https://448889121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbjY0HseEqu7LtYAt4d%2Fuploads%2Fgit-blob-3023d64daf3103d1f659a7d54247456aa22836cc%2Fimage%20(70).png?alt=media" alt=""><figcaption></figcaption></figure>

Datasaur only reads. It never writes to your SharePoint site.
