Skip to content

OneDrive

Automatically upload signed PDFs to Microsoft OneDrive when all signatures are complete.


  • WPsigner 2.1.0+
  • A Microsoft account (personal, work, or school)
  • An Azure App Registration with Graph API permissions

  1. Go to Azure App Registrations
  2. Click New registration
  3. Name: “WPsigner Backup”
  4. Supported account types: Accounts in any organizational directory and personal Microsoft accounts
  5. Redirect URI (Web):
https://your-site.com/wp-admin/admin.php?page=wpsigner-onedrive
  1. Click Register
  2. Copy the Application (client) ID
  1. Go to Certificates & secrets → New client secret
  2. Description: “WPsigner”
  3. Expiration: Choose duration
  4. 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.

  1. Go to API permissions → Add a permission
  2. Choose Microsoft Graph → Delegated permissions
  3. Add: Files.ReadWrite.All, User.Read, offline_access
  4. Click Grant admin consent if required
  1. Go to WPsigner → Integrations → OneDrive
  2. Enter your Application ID and Client Secret
  3. Click Save Settings
  4. Click Authorize OneDrive
  5. Sign in and approve permissions
  6. You’ll be redirected back showing Connected

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 SizeUpload MethodDetails
< 4 MBSimple PUT uploadSingle HTTP request to /me/drive/root:/{path}:/content
≥ 4 MBChunked upload sessionCreates an upload session, then streams in 10 MB chunks

Files are uploaded to OneDrive:/WPsigner/Title_Date_ID.pdf.

For files 4 MB or larger, WPsigner uses the Microsoft Graph upload session API:

  1. Create sessionPOST to /createUploadSession with conflict behavior set to rename
  2. Stream chunks — Sequential PUT requests with Content-Range headers, each carrying up to 10 MB
  3. Finalize — The last chunk response confirms the file creation
  4. Cleanup — Local file handle is closed; audit trail entry is logged

The default file naming pattern is:

{folder}/{sanitized_title}_{date}_{document_id}.pdf
SegmentExampleDescription
{folder}WPsignerConfigurable in settings (default: WPsigner)
{sanitized_title}Service-AgreementDocument title, sanitized for safe file names
{date}2026-03-06Signing date in Y-m-d format
{document_id}142Internal WPsigner document ID

Full path example:

WPsigner/Service-Agreement_2026-03-06_142.pdf

You can change the destination folder in WPsigner → Integrations → OneDrive. OneDrive creates the folder automatically if it doesn’t exist.

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);

ScenarioConfiguration
Personal document archiveConnect with a personal Microsoft account
Corporate compliance storageUse a work/school account with SharePoint-backed OneDrive
Team-accessible contractsSet the folder to a shared OneDrive directory
Multi-cloud backupPair with Dropbox or Amazon S3
Large document supportChunked upload handles PDFs of any size automatically

ComponentSupported Versions
WPsigner2.1.0+
WordPress6.0+
PHP7.4+
Microsoft Graph APIv1.0
Microsoft AccountsPersonal, Work, School
OneDrive PlansAll plans (Free, Microsoft 365, OneDrive for Business)
Max file sizeUnlimited (chunked upload for files ≥ 4 MB)
MultisiteSupported (per-site configuration)

FeatureDetails
Microsoft IdentityOAuth 2.0 via login.microsoftonline.com
AES-256-GCMClient secret and tokens encrypted at rest
Token RefreshAutomatic refresh via offline_access scope
Rate LimitingTest: 5/min, Save: 10/min per user

IssueCauseSolution
”Not connected. Please authorize first.”OAuth tokens are missing or revokedClick Authorize OneDrive to reconnect
”Security check failed”Nonce expiredRefresh the page and retry
”Too many requests”Rate limit exceededWait 60 seconds and retry
Token refresh fails silentlyClient secret expired in AzureCreate a new client secret in Azure, update it in WPsigner, and re-authorize
AADSTS700016 error during authApplication ID is incorrectVerify the Application (client) ID matches your Azure registration
AADSTS65001 — consent requiredAdmin consent not grantedAsk your Azure AD admin to grant consent for the app permissions
”Upload failed” with 403Insufficient Graph API permissionsEnsure Files.ReadWrite.All is granted and consented
”Failed to create upload session”OneDrive storage is fullFree up space or upgrade the OneDrive plan
Files appear in wrong locationFolder name was changed after authorizationVerify the folder setting in WPsigner matches your intended path
Chunked upload hangsServer timeout too lowIncrease PHP max_execution_time (recommended: 300+ for large files)

Filter the full OneDrive path before upload.

Parameters:

ParameterTypeDescription
$onedrive_pathstringFull OneDrive path (e.g., WPsigner/Title_2026-03-06_42.pdf)
$document_idintWPsigner document ID
$documentobjectDocument object

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);