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

# OneDrive

> Set up the OneDrive resource in Python.

## Dependencies

No additional dependencies - uses `aiohttp` (included).

For credential setup, see the [OneDrive Setup](/home/setup/onedrive) guide.

## Configuration

```python theme={null}
import os
from mirage import Workspace, MountMode
from mirage.resource.onedrive import OneDriveConfig, OneDriveResource

config = OneDriveConfig(
    access_token=os.environ["ONEDRIVE_ACCESS_TOKEN"],
    drive_id=os.environ.get("ONEDRIVE_DRIVE_ID"),  # omit for delegated /me/drive
)
resource = OneDriveResource(config=config)
ws = Workspace({"/onedrive/": resource}, mode=MountMode.WRITE)
```

## Config Reference

| Field          | Required | Description                                                            |
| -------------- | -------- | ---------------------------------------------------------------------- |
| `access_token` | Yes      | Microsoft Graph OAuth2 bearer token                                    |
| `drive_id`     | No       | Target a specific drive. Required for app-only tokens (no `/me/drive`) |
| `site_id`      | No       | Resolve a SharePoint site's default drive instead of `/me/drive`       |
| `key_prefix`   | No       | Mount a sub-folder of the drive as the root                            |
| `timeout`      | No       | Request timeout in seconds (default `30`)                              |

Drive resolution order: `drive_id` -> the `site_id` site's default drive ->
`/me/drive`.
