> ## Documentation Index
> Fetch the complete documentation index at: https://ai-kb.automationanywhere.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft OneDrive Toolkit

> Connect OneDrive to EKB Platform agents and workflows to browse, read, write, and share files across personal and team drives.

The Microsoft OneDrive toolkit connects a OneDrive account to EKB Platform using OAuth and lets agents and workflows list drives and folder contents, search and read files, upload and manage files and folders, and create sharing links. The toolkit uses Microsoft Graph and runs with the connected user's OneDrive permissions.

## Prerequisites

* A Microsoft work or school account with access to the OneDrive files you intend to use.
* An EKB Platform project where you can configure an agent or workflow.
* Your EKB Platform administrator must have configured a Microsoft OAuth integration with the required Graph permissions (`Files.ReadWrite.All` and `Sites.ReadWrite.All` for site drives) before you can connect.
* For shared-with-me items, `Files.ReadWrite.All` must be consented by your administrator.

<Warning>
  Enable only the operations required for the task. Leave write, delete, move, and sharing tools disabled until explicitly needed. Test write operations on a disposable folder first. Never pass a display name as an item ID — always use the `item_id` and `drive_id` values returned by list or search tools.
</Warning>

## Setup

<Steps>
  <Step title="Open an agent or workflow in EKB Platform">
    Create or open an EKB Platform agent and add the **Microsoft OneDrive** toolkit, or add a Microsoft OneDrive node to a workflow.
  </Step>

  <Step title="Enable only the tools you need">
    Start with read-only tools: **List Drives**, **List Folder Contents**, **Search Files**, **Get File Metadata**, and **Read File Content**. Leave write and sharing tools disabled until needed.
  </Step>

  <Step title="Sign in with Microsoft">
    Send a request or select the Microsoft sign-in action when EKB Platform prompts for it. Sign in with the Microsoft work or school account that owns the files and grant the requested permissions.
  </Step>

  <Step title="Test with read actions first">
    Run **List Drives** and **List Folder Contents** to confirm access. Use a disposable test folder for any write operations and verify the results in OneDrive on the web after each write test.
  </Step>
</Steps>

## Available tools

### Navigate

| Tool                     | Description                                                                                    |
| ------------------------ | ---------------------------------------------------------------------------------------------- |
| **List Drives**          | Lists the personal drive and accessible group or site drives. Run this first to get drive IDs. |
| **List Folder Contents** | Lists files and folders in a folder. Prefer item ID over path.                                 |
| **Get Folder Tree**      | Returns a depth- and breadth-capped folder tree (max depth 5).                                 |
| **Get File Metadata**    | Returns ID, name, size, modified time, web URL, and folder or file flags for an item.          |
| **Get Special Folder**   | Resolves a well-known folder such as Documents or Photos.                                      |

### Discover

| Tool                    | Description                                                                       |
| ----------------------- | --------------------------------------------------------------------------------- |
| **Search Files**        | Searches OneDrive by file name or keyword. Optional drive ID and result limit.    |
| **List Recent Files**   | Returns recently accessed items, ordered by activity.                             |
| **List Shared With Me** | Lists files shared with the signed-in user. Requires `Files.ReadWrite.All`.       |
| **Resolve Sharing URL** | Converts a OneDrive, SharePoint, or 1drv.ms sharing link into drive and item IDs. |

### Read

| Tool                  | Description                                                                                                             |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Read File Content** | Extracts text from a file. Text files capped at 10 MB; binary at 50 MB; extracted text truncated at 100,000 characters. |
| **Export Item**       | Exports an Office document to PDF and extracts its text.                                                                |
| **Get Preview Link**  | Returns a short-lived preview URL for a file.                                                                           |
| **Get Item Versions** | Lists previous versions of a file.                                                                                      |
| **List Permissions**  | Lists sharing permissions on a file or folder.                                                                          |

### Write

| Tool              | Description                                                                                                    |
| ----------------- | -------------------------------------------------------------------------------------------------------------- |
| **Upload File**   | Uploads a new file. Files larger than 4 MB use a chunked upload session. Conflict behavior defaults to rename. |
| **Create Folder** | Creates a folder under a parent item or path.                                                                  |
| **Update File**   | Overwrites an existing file. Re-read metadata first if the file may have changed.                              |
| **Rename Item**   | Renames a file or folder by item ID.                                                                           |
| **Move Item**     | Moves a file or folder to a new location by item ID.                                                           |
| **Copy Item**     | Copies a file or folder. Copy is asynchronous and may still be in progress when the tool returns.              |
| **Delete Item**   | Moves the item to the recycle bin. Recycle-bin deletes do not free drive quota.                                |

### Share

| Tool                     | Description                                                                                            |
| ------------------------ | ------------------------------------------------------------------------------------------------------ |
| **Create Sharing Link**  | Creates a view or edit sharing link with organization or anonymous scope, as allowed by tenant policy. |
| **Invite Users To Item** | Invites people by email with read or write roles.                                                      |

## Use cases

* Search OneDrive for a quarterly report, read its content, and summarize it in a workflow.
* Upload a generated file to a team drive folder and create a sharing link for stakeholders.
* List folder contents and find recently modified files before triggering a downstream notification.
* Export a Word document to PDF and pass the extracted text to an agent for analysis.
* Resolve a sharing URL from a Slack message into a file ID and read its content directly.

## Troubleshooting

| Symptom                                         | Likely cause                                                                                               | Fix                                                                                                                                            |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| Redirect URI mismatch                           | The OAuth redirect URI in Microsoft Entra does not exactly match the one in EKB Platform Super Admin.      | Ask your administrator to ensure both URIs match exactly, including protocol and path.                                                         |
| `AADSTS53003` Conditional Access error          | The Microsoft Entra tenant blocks app-only token issuance.                                                 | This is expected for user OneDrive data — users must sign in with the delegated OAuth flow. The Super Admin connection test can still succeed. |
| `403` insufficient permissions                  | The required Graph permissions have not been consented by an administrator.                                | Ask your administrator to grant `Files.ReadWrite.All` and `Sites.ReadWrite.All` for site drives.                                               |
| `404` item not found                            | The item ID is incorrect, the wrong drive ID is specified, or OneDrive is not provisioned for the account. | Use **List Drives** and **List Folder Contents** to find the correct `item_id` and `drive_id`.                                                 |
| `412` lost update on file write                 | The file changed between when it was read and when the write was attempted.                                | Re-read the file metadata and retry the write operation.                                                                                       |
| `507` insufficient storage                      | The drive is full. Recycle-bin deletes do not free quota.                                                  | Empty the recycle bin in OneDrive on the web to free space.                                                                                    |
| File is locked or checked out                   | Another user has the file open for editing.                                                                | Wait for the owner to close or check in the file, then retry.                                                                                  |
| Workflow cannot use a file from a previous step | A display name was passed instead of an item ID.                                                           | Use the Variables picker to pass the prior node's `id` and `drive_id` values — not the file's display name.                                    |
