OneDrive
Automatically upload signed PDFs to Microsoft OneDrive when all signatures are complete.
Requirements
Section titled “Requirements”- WPsigner 2.1.0+
- A Microsoft account (personal, work, or school)
- An Azure App Registration with Graph API permissions
Step 1: Register an Azure App
Section titled “Step 1: Register an Azure App”- Go to Azure App Registrations
- Click New registration
- Name: “WPsigner Backup”
- Supported account types: Accounts in any organizational directory and personal Microsoft accounts
- Redirect URI (Web):
https://your-site.com/wp-admin/admin.php?page=wpsigner-onedrive- Click Register
- Copy the Application (client) ID
Step 2: Create Client Secret
Section titled “Step 2: Create Client Secret”- Go to Certificates & secrets → New client secret
- Description: “WPsigner”
- Expiration: Choose duration
- Copy the Value (not the ID)
Copy the client secret value immediately after creation. Azure only shows it once. If you lose it, you must create a new secret.
Step 3: Add API Permissions
Section titled “Step 3: Add API Permissions”- Go to API permissions → Add a permission
- Choose Microsoft Graph → Delegated permissions
- Add:
Files.ReadWrite.All,User.Read,offline_access - Click Grant admin consent if required
Step 4: Configure WPsigner
Section titled “Step 4: Configure WPsigner”- Go to WPsigner → Integrations → OneDrive
- Enter your Application ID and Client Secret
- Click Save Settings
- Click Authorize OneDrive
- Sign in and approve permissions
- You’ll be redirected back showing Connected
How It Works
Section titled “How It Works”When all signers complete their signatures, WPsigner uploads the signed PDF to OneDrive via the Microsoft Graph API. The upload method is selected automatically based on file size:
| File Size | Upload Method | Details |
|---|---|---|
| < 4 MB | Simple PUT upload | Single HTTP request to /me/drive/root:/{path}:/content |
| ≥ 4 MB | Chunked upload session | Creates an upload session, then streams in 10 MB chunks |
Files are uploaded to OneDrive:/WPsigner/Title_Date_ID.pdf.
Chunked Upload Process
Section titled “Chunked Upload Process”For files 4 MB or larger, WPsigner uses the Microsoft Graph upload session API:
- Create session —
POSTto/createUploadSessionwith conflict behavior set torename - Stream chunks — Sequential
PUTrequests withContent-Rangeheaders, each carrying up to 10 MB - Finalize — The last chunk response confirms the file creation
- Cleanup — Local file handle is closed; audit trail entry is logged
File Naming
Section titled “File Naming”The default file naming pattern is:
{folder}/{sanitized_title}_{date}_{document_id}.pdf| Segment | Example | Description |
|---|---|---|
{folder} | WPsigner | Configurable in settings (default: WPsigner) |
{sanitized_title} | Service-Agreement | Document title, sanitized for safe file names |
{date} | 2026-03-06 | Signing date in Y-m-d format |
{document_id} | 142 | Internal WPsigner document ID |
Full path example:
WPsigner/Service-Agreement_2026-03-06_142.pdfYou can change the destination folder in WPsigner → Integrations → OneDrive. OneDrive creates the folder automatically if it doesn’t exist.
Custom Paths
Section titled “Custom Paths”Use the wps_onedrive_backup_path filter to customize the path dynamically:
add_filter('wps_onedrive_backup_path', function ($onedrive_path, $document_id, $document) { $year = wp_date('Y'); return "WPsigner/{$year}/" . basename($onedrive_path);}, 10, 3);Use Cases
Section titled “Use Cases”| Scenario | Configuration |
|---|---|
| Personal document archive | Connect with a personal Microsoft account |
| Corporate compliance storage | Use a work/school account with SharePoint-backed OneDrive |
| Team-accessible contracts | Set the folder to a shared OneDrive directory |
| Multi-cloud backup | Pair with Dropbox or Amazon S3 |
| Large document support | Chunked upload handles PDFs of any size automatically |
Compatibility
Section titled “Compatibility”| Component | Supported Versions |
|---|---|
| WPsigner | 2.1.0+ |
| WordPress | 6.0+ |
| PHP | 7.4+ |
| Microsoft Graph API | v1.0 |
| Microsoft Accounts | Personal, Work, School |
| OneDrive Plans | All plans (Free, Microsoft 365, OneDrive for Business) |
| Max file size | Unlimited (chunked upload for files ≥ 4 MB) |
| Multisite | Supported (per-site configuration) |
Security
Section titled “Security”| Feature | Details |
|---|---|
| Microsoft Identity | OAuth 2.0 via login.microsoftonline.com |
| AES-256-GCM | Client secret and tokens encrypted at rest |
| Token Refresh | Automatic refresh via offline_access scope |
| Rate Limiting | Test: 5/min, Save: 10/min per user |
Troubleshooting
Section titled “Troubleshooting”| Issue | Cause | Solution |
|---|---|---|
| ”Not connected. Please authorize first.” | OAuth tokens are missing or revoked | Click Authorize OneDrive to reconnect |
| ”Security check failed” | Nonce expired | Refresh the page and retry |
| ”Too many requests” | Rate limit exceeded | Wait 60 seconds and retry |
| Token refresh fails silently | Client secret expired in Azure | Create a new client secret in Azure, update it in WPsigner, and re-authorize |
AADSTS700016 error during auth | Application ID is incorrect | Verify the Application (client) ID matches your Azure registration |
AADSTS65001 — consent required | Admin consent not granted | Ask your Azure AD admin to grant consent for the app permissions |
| ”Upload failed” with 403 | Insufficient Graph API permissions | Ensure Files.ReadWrite.All is granted and consented |
| ”Failed to create upload session” | OneDrive storage is full | Free up space or upgrade the OneDrive plan |
| Files appear in wrong location | Folder name was changed after authorization | Verify the folder setting in WPsigner matches your intended path |
| Chunked upload hangs | Server timeout too low | Increase PHP max_execution_time (recommended: 300+ for large files) |
Developer Hooks
Section titled “Developer Hooks”wps_onedrive_backup_path
Section titled “wps_onedrive_backup_path”Filter the full OneDrive path before upload.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$onedrive_path | string | Full OneDrive path (e.g., WPsigner/Title_2026-03-06_42.pdf) |
$document_id | int | WPsigner document ID |
$document | object | Document object |
wps_onedrive_uploaded
Section titled “wps_onedrive_uploaded”Action fired after a successful upload.
add_action('wps_onedrive_uploaded', function ($document_id, $onedrive_path) { error_log("Document {$document_id} backed up to OneDrive: {$onedrive_path}");}, 10, 2);Next Steps
Section titled “Next Steps”- Dropbox — Dropbox backup
- Google Drive — Google Drive backup
- Amazon S3 — S3 bucket storage
- Cloudflare R2 — Zero egress, global CDN
- Wasabi — S3-compatible, no egress fees