Package Information
Documentation
Microsoft OneDrive (Business) Node for n8n
This is a complete implementation of a Microsoft OneDrive for Business node for n8n, built on SharePoint Document Library with Microsoft Graph API.
🚀 Features
Resources & Operations
File Operations
- ✅ Delete - Remove files from OneDrive
- ✅ Download - Download file content as binary data
- ✅ Get - Retrieve file metadata
- ✅ Rename - Change file names
- ✅ Search - Find files by query
- ✅ Share - Create sharing links with configurable permissions
- ✅ Upload - Upload files from binary data
Folder Operations
- ✅ Create - Create new folders
- ✅ Delete - Remove folders
- ✅ Get Items - List contents of a folder
- ✅ Rename - Change folder names
- ✅ Search - Find folders by query
- ✅ Share - Create sharing links with configurable permissions
Triggers (Webhook-based)
- ⚡ On File Created - Triggers when a new file is created
- ⚡ On File Updated - Triggers when a file is modified
- ⚡ On Folder Created - Triggers when a new folder is created
- ⚡ On Folder Updated - Triggers when a folder is modified
📋 Prerequisites
Microsoft Azure App Registration
Go to Azure Portal
Navigate to Azure Active Directory > App registrations > New registration
Configure:
- Name:
n8n OneDrive Business Integration - Supported account types: Accounts in any organizational directory
- Redirect URI:
https://your-n8n-instance.com/rest/oauth2-credential/callback
- Name:
After creation, note down:
- Application (client) ID
- Directory (tenant) ID
Go to Certificates & secrets > New client secret
- Note down the Client secret value (shown only once!)
Go to API permissions > Add a permission > Microsoft Graph > Delegated permissions
- Add these permissions:
Files.ReadWrite.AllSites.Read.AllSites.ReadWrite.Alloffline_access
- Click Grant admin consent
- Add these permissions:
🔧 Installation
For n8n Community Nodes
- Copy Files to n8n Custom Nodes Directory:
# Navigate to your n8n installation
cd ~/.n8n/custom
# Create directory structure
mkdir -p nodes/MicrosoftOneDriveBusiness
mkdir -p credentials
# Copy credential file
cp credentials/MicrosoftOneDriveBusinessOAuth2Api.credentials.ts ~/.n8n/custom/credentials/
# Copy node files
cp nodes/MicrosoftOneDriveBusiness/* ~/.n8n/custom/nodes/MicrosoftOneDriveBusiness/
- Install as Community Node (Alternative):
If published as an npm package:
# In n8n UI: Settings > Community Nodes > Install
# Package name: n8n-nodes-microsoft-onedrive-business
For Development
# Clone repository
git clone <repository-url>
cd n8n-onedrive-business
# Install dependencies
npm install
# Link to n8n
npm link
# In your n8n directory
npm link n8n-nodes-microsoft-onedrive-business
⚙️ Configuration
1. Add Credentials in n8n
- Go to Credentials > New > Microsoft OneDrive (Business) OAuth2 API
- Enter:
- Client ID: Your Azure App's Application (client) ID
- Client Secret: Your Azure App's client secret
- Click Connect my account and authorize
2. Get Site ID and Drive ID
To use the node, you need your SharePoint site ID:
Get Site ID:
GET https://graph.microsoft.com/v1.0/sites/{hostname}:/{site-path}
Example:
GET https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/TeamSite
Get Drive ID (optional - will auto-fetch if not provided):
GET https://graph.microsoft.com/v1.0/sites/{site-id}/drive
📖 Usage Examples
Example 1: Upload a File
{
"nodes": [
{
"parameters": {
"resource": "file",
"operation": "upload",
"siteId": "contoso.sharepoint.com,abc123,def456",
"parentFolderId": "root",
"fileName": "report.pdf",
"binaryPropertyName": "data"
},
"name": "Upload to OneDrive",
"type": "n8n-nodes-microsoftOneDriveBusiness.microsoftOneDriveBusiness",
"credentials": {
"microsoftOneDriveBusinessOAuth2Api": "OneDrive Business Credentials"
}
}
]
}
Example 2: Search and Download Files
{
"nodes": [
{
"parameters": {
"resource": "file",
"operation": "search",
"siteId": "contoso.sharepoint.com,abc123,def456",
"query": "quarterly report"
},
"name": "Search Files"
},
{
"parameters": {
"resource": "file",
"operation": "download",
"fileId": "={{ $json.id }}",
"binaryProperty": "data"
},
"name": "Download File"
}
]
}
Example 3: Trigger on New Files
{
"nodes": [
{
"parameters": {
"siteId": "contoso.sharepoint.com,abc123,def456",
"event": "fileCreated",
"watchFolderId": "root"
},
"name": "OneDrive Trigger",
"type": "n8n-nodes-microsoftOneDriveBusiness.microsoftOneDriveBusinessTrigger"
}
]
}
🔑 Key Differences from OneDrive Personal
| Feature | OneDrive Personal | OneDrive Business |
|---|---|---|
| Backend | Consumer OneDrive | SharePoint |
| Drive Type | personal |
business |
| API Base | /me/drive |
/sites/{id}/drive |
| Authentication | Personal Microsoft Account | Azure AD (Work/School) |
| Organization Features | ❌ | ✅ (Sharing policies, DLP, etc.) |
🛠️ API Endpoints Used
GET /sites/{site-id}/drive- Get drive informationPUT /drives/{drive-id}/items/{parent-id}:/{filename}:/content- Upload fileGET /drives/{drive-id}/items/{item-id}/content- Download fileGET /drives/{drive-id}/items/{item-id}- Get metadataDELETE /drives/{drive-id}/items/{item-id}- Delete itemPATCH /drives/{drive-id}/items/{item-id}- Update itemGET /drives/{drive-id}/root/search(q='{query}')- SearchPOST /drives/{drive-id}/items/{item-id}/createLink- Create sharing linkPOST /subscriptions- Create webhook subscription (triggers)GET /drives/{drive-id}/root/delta- Get delta changes (triggers)
🐛 Troubleshooting
"Drive not found" error
- Verify your Site ID is correct
- Ensure user has access to the SharePoint site
- Check that the drive exists for the site
"Insufficient privileges" error
- Verify all required Graph API permissions are granted
- Ensure admin consent is given for tenant-wide permissions
- Check that the user has appropriate SharePoint permissions
Webhook/Trigger not working
- Ensure your n8n instance is publicly accessible
- Verify the webhook URL is correct
- Check that subscriptions are being created (they expire after 72 hours)
- Microsoft Graph webhook delivery can have delays
File upload fails
- Check file size (large files >4MB need resumable upload session)
- Verify binary data property name is correct
- Ensure mime type is set correctly
📚 Resources
- Microsoft Graph API Documentation
- SharePoint API Documentation
- n8n Node Development
- Azure App Registration
📄 License
MIT License - Feel free to use and modify as needed.
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
✨ Credits
Built for n8n following official node development guidelines.
Implements OneDrive for Business (SharePoint) only - does not support OneDrive Personal.