> 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-onedrive.md).

# Microsoft OneDrive

Connect a OneDrive account (whole drive or one folder) to Datasaur to attach the drive to a knowledge base, which keeps its documents in sync on a schedule you set.

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

## Prerequisites

* A Microsoft account (Personal) or a Microsoft 365 account (Business).
* Permission to register an application in the Azure Portal, or an admin who can do it for you.

## 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-d6bad3d3d0f584934175f3ddab891268743a6520%2Fimage%20(71).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 OneDrive`.
4. Under **Supported account types**, choose **Accounts in any organizational directory and personal Microsoft accounts** if you are connecting a personal OneDrive. For Business only, the default single-tenant option works.
5. Under **Redirect URI**, select **Web** and enter:

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

   On Datasaur Cloud, use `https://llm.datasaur.ai/api/eos/authorization/onedrive`. 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**.

{% hint style="info" %}
A single-tenant registration rejects personal Microsoft accounts at sign-in.
{% endhint %}

#### 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-cebcf7740cdb02db5523171a291db94cc341dfe4%2Fimage%20(73).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`, then click **Add permissions**.
4. For a Business account, click **Grant admin consent** if your tenant requires it. Personal accounts consent at sign-in instead. 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. `Sites.Read.All` is not needed — that is for the SharePoint integration.

#### 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-6e114281e6ecec5a5a61bc6d8043925b92690ace%2Fimage%20(74).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="info" %}
The Value is shown only once. Note the expiry date too: when the secret expires, the connection stops syncing.
{% endhint %}

#### Step 4 — Get the Folder URL (optional)

Leave this blank to connect your whole drive. To connect one folder, right-click it in OneDrive, select **Share**, and click **Copy link**.

The URL must point to a folder, not a file, and must belong to the account you sign in with. A Personal link will not work with a Business account, or the reverse.\
You can also paste a URL copied from the OneDrive address bar, but only if it contains an id= parameter. Without it, Datasaur connects your whole drive and gives no error.\
A SharePoint site URL is rejected. Use the SharePoint integration instead.

<table><thead><tr><th width="105.20001220703125">Account</th><th>Example</th></tr></thead><tbody><tr><td>Personal</td><td><code>https://1drv.ms/f/c/xxxxxxxxxxxx/...</code></td></tr><tr><td>Business</td><td><code>https://contoso-my.sharepoint.com/:f:/g/personal/user_contoso_com/...</code></td></tr></tbody></table>

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

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

   <table><thead><tr><th width="204.79998779296875">Field</th><th>Required</th><th>Notes</th></tr></thead><tbody><tr><td>Azure AD Application (client) ID</td><td>Yes</td><td>From Step 1.</td></tr><tr><td>Client secret</td><td>Yes, for a Web registration</td><td>From Step 3.</td></tr><tr><td>Tenant ID</td><td>Only for single-tenant apps</td><td>From Step 1.</td></tr><tr><td>Folder URL</td><td>No</td><td>Blank connects your <strong>My files</strong>.</td></tr></tbody></table>
4. Click **Authorize**
5. Sign in with the Microsoft account that owns the drive 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-b3ad1ab168f7f52a5199d1906981b9df04f0c81f%2Fimage%20\(75\).png?alt=media)
6. You return to Datasaur. The connection is named after what it resolved to, such as `(user@contoso.com) My files`, or that name plus the folder path for a scoped connection. You can rename it.

{% 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 OneDrive 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-186a9baa0f2ae4e664e0de48d695ac48f98df504%2Fimage%20(77).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-97f55fd56a178fa00aa33f480026c9fb8965a952%2Fimage%20\(78\).png?alt=media)

The connection syncs everything in scope 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.

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

You can add several connections for different folders on the same drive. Renaming or moving a connected folder does not break the connection. Folders shared with you can be connected too.
