SharePoint Integration
List, download, and manage files programmatically with SharePoint integration and Microsoft Graph API.
Timbal integrates with SharePoint to enable listing, downloading, and managing files programmatically.
This integration allows you to access both personal and shared files across different scopes in your SharePoint environment.
Prerequisites
Before using the SharePoint integration, you'll need:
- A Microsoft 365 tenant
- A registered application in Azure Portal with:
- Application (client) ID
- Directory (tenant) ID
- Client secret
- Required permissions configured:
- Files.Read.All
- Sites.Read.All
- A
token_sharepoint.json
file with your credentials
Authentication Setup
The first time you use the integration, you'll be prompted to authenticate:
This will open a browser window for Microsoft sign-in and create a token file for future use.
Installation
Install the requirements by doing:
List Directory
Description
The list_directory step allows you to list files and folders in SharePoint, with support for both personal and shared files across different scopes.
Example
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
folder | str | The SharePoint folder path to list contents from | No |
scope | str | Where to search for files: 'my-files', 'shared', or 'all' | No |
output_path | str | Path to save the output JSON file | No |
Download File
Description
The download_file step allows you to download files from SharePoint by searching for them across different scopes.
Example
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
file | str | Name or ID of the file to find and download | Yes |
destination | str | Directory where the file will be downloaded to. If None, uses the current working directory | No |
folder | str | Optional path to a specific folder to search in | No |
scope | str | Search scope ('my-files', 'shared', or 'all'). Defaults to 'my-files' | No |
Agent Integration Example
Notes
- Make sure your Microsoft 365 tenant and app registration are properly configured
- The first authentication will prompt a browser sign-in and create a token file for future use
- File names are case-sensitive
- If multiple files with the same name exist, an error will be raised
- Ensure you have the necessary permissions to access the files
- For more advanced usage, see the Microsoft Graph API documentation