Package Information
Documentation
n8n OneDrive Shared Files Node
A powerful n8n node for accessing and managing OneDrive files shared with you, featuring device flow authentication and WhatsApp notifications for seamless workflow automation.
š Features
- List Shared Files: Browse all OneDrive files shared with your account
- File Picker: Select specific shared files by type (Excel, Word, PDF, PowerPoint)
- PRF Query: Advanced filtering for Purchase Request Form data in Excel sheets
- Worksheet Query: Extract specific columns from any Excel worksheet
- Smart Caching: Configurable file caching to improve performance
- Device Flow Authentication: Secure OAuth2 device code flow for Microsoft Graph API
- š WhatsApp Integration: Send authentication notifications directly to WhatsApp
- š Force Re-login: Immediate authentication refresh with instant feedback
- š Mobile-First: Get device codes and verification URLs on your phone
š Prerequisites
- n8n instance (self-hosted or cloud)
- Microsoft Azure App Registration with appropriate permissions
- Node.js and npm/yarn for development
š§ Installation
1. Azure App Registration Setup
- Go to Azure Portal ā App registrations
- Create a new registration:
- Name:
n8n-onedrive-shared - Supported account types: Accounts in this organizational directory only
- Redirect URI: Not required for device flow
- Name:
- Note down:
- Application (client) ID
- Directory (tenant) ID
- Configure API permissions:
- Microsoft Graph ā Delegated permissions
- Add
Files.ReadWrite.All - Grant admin consent
2. Node Installation
Option A: Install from npm (Recommended)
# Install the node package
npm install n8n-nodes-onedrive-shared
# Restart your n8n instance
Option B: Manual Installation
# Clone or download this repository
git clone <repository-url>
cd n8n-onedrive-shared
# Install dependencies
npm install
# Build the node
npm run build
# Copy to your n8n custom nodes directory
cp -r dist/* ~/.n8n/custom/
3. WhatsApp API Setup (Optional)
For WhatsApp notifications during authentication:
- Set up a WhatsApp Business API server (e.g., using WhatsApp Business API)
- Configure the API endpoint URL
- Add WhatsApp API credentials in n8n:
- WhatsApp API URL: Your WhatsApp API server endpoint
- Default WhatsApp Number: Optional fallback number
4. n8n Configuration
- Restart your n8n instance
- Create new credentials:
- Type: OneDrive Device-Code Flow
- Client ID: Your Azure app client ID
- Tenant ID: Your Azure tenant ID
- Scopes:
Files.ReadWrite.All(default)
šÆ Operations
1. List Shared Files
Retrieve all files shared with your OneDrive account.
Output: Array of file objects with name, ID, drive ID, and owner information.
2. Pick a Shared File
Select a specific shared file filtered by file type.
Parameters:
- File Type: xlsx, docx, pdf, pptx
- File: Dropdown populated with matching shared files
Output: Selected file details.
3. Query PRF Status
Advanced filtering for Purchase Request Form data in Excel worksheets.
Parameters:
- File Type: Excel (.xlsx)
- File: Target Excel file
- Sheet Name: Worksheet to query
- Description contains: Filter by description text
- Submitter contains: Filter by submitter name
- PRF No equals: Exact PRF number match
- Status contains: Filter by status text
- Additional Keywords: Comma-separated keywords for description
- Date Submit (exact): Exact date match (YYYY-MM-DD)
- Cache Duration: Minutes to cache downloaded file
Output: Filtered PRF records matching all specified criteria.
4. Query Worksheet
Extract specific columns from any Excel worksheet.
Parameters:
- File Type: Excel (.xlsx)
- File: Target Excel file
- Sheet Name: Worksheet to query
- Columns to Extract: Multi-select dropdown of available columns
- Cache Duration: Minutes to cache downloaded file
Output: Array of records with selected column data.
š Authentication Flow
This node uses Microsoft's Device Code Flow for authentication:
- When first used, the node will display a device code and URL
- Visit the URL and enter the device code
- Sign in with your Microsoft account
- Tokens are automatically cached for future use
- Tokens refresh automatically when expired
š¾ Caching System
Token Caching
- Location:
~/.n8n/onedrive_token_cache.json - Automatic refresh handling
- Secure storage of access/refresh tokens
File Caching
- Location:
~/.n8n/onedrive_cache/ - Configurable TTL (default: 60 minutes)
- Reduces API calls and improves performance
- Files are re-downloaded when cache expires
šļø Architecture
src/
āāā credentials/
ā āāā OneDriveDeviceFlow.credentials.ts # OAuth2 device flow credentials
āāā lib/
ā āāā oneDrive.ts # Core Microsoft Graph API logic
āāā nodes/
ā āāā OneDriveShared.node.ts # Main node implementation
āāā index.ts # Node registration
Key Components
- MSAL Integration: Uses
@azure/msal-nodefor secure authentication - Excel Processing:
exceljslibrary for worksheet manipulation - Graph API Client:
axiosfor Microsoft Graph API calls - Smart Caching: File-based caching with TTL support
š PRF Query Features
The PRF Query operation is specifically designed for Purchase Request Form processing:
- Flexible Filtering: Multiple filter criteria can be combined
- Case-Insensitive Matching: Text searches ignore case
- Date Normalization: Handles various date formats
- Keyword Matching: Additional keywords for description filtering
- Exact Matching: PRF numbers require exact matches
Expected PRF Sheet Structure
| Column Name | Description |
|---|---|
| PRF No | Purchase Request Form number |
| Description | Item/service description |
| Submit By | Person who submitted the request |
| Date Submit | Submission date |
| Status in Pronto | Current status |
š ļø Development
Building
npm run build
TypeScript Configuration
- Target: ES2020
- Module: CommonJS
- Strict mode enabled
- Output:
dist/directory
Dependencies
@azure/msal-node: Microsoft Authentication Libraryaxios: HTTP client for Graph APIexceljs: Excel file processingn8n-workflow: n8n node development framework
š Troubleshooting
Common Issues
Authentication Errors
- Verify Azure app permissions
- Check tenant/client IDs
- Ensure admin consent is granted
File Access Issues
- Confirm files are actually shared with your account
- Check file permissions in OneDrive
- Verify file types match filters
Cache Issues
- Clear cache directory:
~/.n8n/onedrive_cache/ - Reset token cache:
~/.n8n/onedrive_token_cache.json
- Clear cache directory:
Debug Mode
Enable n8n debug logging to see detailed API calls and responses:
N8N_LOG_LEVEL=debug n8n start
š License
This project is licensed under the MIT License.
š¤ Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
š Support
For issues and questions:
- Check the troubleshooting section
- Review n8n community forums
- Create an issue in the repository
Version: 0.1.0
Last Updated: August 11, 2025
Compatibility: n8n v1.x