onedrive-shared

n8n node for OneDrive shared files management with device flow authentication and WhatsApp notifications

Package Information

Downloads: 0 weeklyĀ /Ā 9 monthly
Latest Version: 1.1.0
Author: TRAE AI Agent

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

  1. Go to Azure Portal → App registrations
  2. Create a new registration:
    • Name: n8n-onedrive-shared
    • Supported account types: Accounts in this organizational directory only
    • Redirect URI: Not required for device flow
  3. Note down:
    • Application (client) ID
    • Directory (tenant) ID
  4. 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:

  1. Set up a WhatsApp Business API server (e.g., using WhatsApp Business API)
  2. Configure the API endpoint URL
  3. Add WhatsApp API credentials in n8n:
    • WhatsApp API URL: Your WhatsApp API server endpoint
    • Default WhatsApp Number: Optional fallback number

4. n8n Configuration

  1. Restart your n8n instance
  2. 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:

  1. When first used, the node will display a device code and URL
  2. Visit the URL and enter the device code
  3. Sign in with your Microsoft account
  4. Tokens are automatically cached for future use
  5. 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-node for secure authentication
  • Excel Processing: exceljs library for worksheet manipulation
  • Graph API Client: axios for 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 Library
  • axios: HTTP client for Graph API
  • exceljs: Excel file processing
  • n8n-workflow: n8n node development framework

šŸ› Troubleshooting

Common Issues

  1. Authentication Errors

    • Verify Azure app permissions
    • Check tenant/client IDs
    • Ensure admin consent is granted
  2. File Access Issues

    • Confirm files are actually shared with your account
    • Check file permissions in OneDrive
    • Verify file types match filters
  3. Cache Issues

    • Clear cache directory: ~/.n8n/onedrive_cache/
    • Reset token cache: ~/.n8n/onedrive_token_cache.json

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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. 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

Discussion