OneDrive Integration
Overview
The WPDM OneDrive add-on enables serving files from Microsoft OneDrive, including personal accounts and OneDrive for Business. Integrate with Microsoft 365, leverage enterprise security features, and manage files through the familiar OneDrive interface.
Prerequisites
Before you begin, ensure you have:
- WordPress 5.0 or higher
- WordPress Download Manager plugin (Free or Pro)
- A Microsoft account (personal or Microsoft 365/Business)
- Administrator access to your WordPress site
Benefits
| Feature | Benefit |
|---|---|
| 5GB Free | Personal accounts |
| 1TB with M365 | Business accounts |
| Microsoft Integration | Part of Office ecosystem |
| Enterprise Security | Compliance features |
| Real time Collaboration | Co-authoring support |
Step 1: Create an Azure AD Application
To connect OneDrive, you need to register an application in Microsoft Azure.
1.1 Access Azure Portal
- Go to Azure Portal
- Sign in with your Microsoft account
- If you don’t have an Azure account, you can create one for free
1.2 Register a New Application
- In the Azure Portal, search for App registrations in the top search bar
- Click App registrations from the results
- Click + New registration button
1.3 Configure Application Details
Fill in the registration form:
Name: WPDM OneDrive Integration (any name you like) Supported account types: ○ Single tenant (organization only) ● Multi-tenant + personal accounts (recommended) ○ Personal Microsoft accounts only Redirect URI: Platform: Web URL: https://yoursite.com/onedrive-redirect
Important: Copy the Redirect URI from Downloads > Settings > OneDrive Connect > Azure AD App Configuration . It should look like this:
https://yoursite.com/onedrive-redirect
- Click Register
1.4 Note Your Application (Client) ID
After registration, you’ll see the app overview page.
- Copy the Application (client) ID
- Store this ID securely, it will be required for Client ID field
Step 2: Create Client Secret
2.1 Generate Secret
- In your Azure app registration, click Manage > Certificates & secrets in the left sidebar
- Under Client secrets, click + New client secret
- Enter a description (e.g.,
WPDM OneDrive Secret) - Choose an expiration period:
- Recommended: 24 months
- You’ll need to generate a new secret before expiration
- Click Add
2.2 Copy Secret Value
Critical: Copy the secret Value immediately! It will only be shown once.
| Column | What to Copy |
|---|---|
| Value | Copy this (the actual secret) |
| Secret ID | Not needed |
Store this value securely – you’ll enter it in Client Secret field.
Step 3: Configure API Permissions
3.1 Add Required Permissions
- Click API permissions in the left sidebar
- Click + Add a permission
- Select Microsoft Graph
- Select Delegated permissions
- Search Files and add these permissions:
| Permission | Description |
|---|---|
Files.Read |
Read user files |
Files.Read.All |
Read all files user can access |
Files.ReadWrite |
Read write user files |
Files.ReadWrite.All |
Read write all user files |
- Click Add permissions
3.2 Verify Permissions
Your API permissions should now show:
☑ Files.Read ☑ Files.Read.All ☑ Files.ReadWrite ☑ Files.ReadWrite.All ☑ offline_access ☑ User.Read
Note: Click Grant admin consent (if admin)
Step 4: Configure WordPress Plugin
4.1 Enter Credentials
- In WordPress admin, go to Downloads → Settings
- Click the OneDrive Connect tab
- Enter your credentials:
| Field | Value |
|---|---|
| Application (Client) ID | Paste the Application ID from Step 1.4 |
| Client Secret | Paste the Secret Value from Step 2.2 |
- Click Save Settings
4.2 Connect Your Account
After saving:
- Click the Connect with OneDrive button
- A popup window will open
- Sign in with your Microsoft account
- Review the permissions and click Accept
- The popup will close automatically
- Redirect back to settings page
- Refresh the page to see your account details
✓ Successfully connected to OneDrive Account Name | user@outlook.com Token expires: Apr 13, 2030 7:35 AM
Step 5: Start Using OneDrive Files
5.1 Attach Files to Downloads
- Create or edit a Download (Downloads → Add New or Downloads → All Downloads)
- In the Attach File section, click Select From OneDrive
- Browse your OneDrive folders
- Click Attach next to any file
- The file will be added to your download package
5.2 Navigation Tips
- Click folders to navigate into them
- Use the back button to go up one level
- The breadcrumb shows your current location
- File size and modification date are shown for each item
Video Tutorial
Troubleshooting
Connection Failed Error
Possible causes:
- Incorrect Client ID or Secret
- Redirect URI mismatch
- Missing API permissions
Solutions:
- Verify Client ID is the Application (client) ID (not Directory ID)
- Ensure Redirect URI in Azure exactly matches the one shown in Azure AD App Configuration
- Check all required API permissions are added
Access Denied After Login
Possible causes:
- Missing API permissions
- Account doesn’t have OneDrive access
Solutions:
- Verify all permissions from Step 3 are added
- Ensure you’re signing in with an account that has OneDrive
Files Not Loading
Possible causes:
- Token expired
- Network issues
Solutions:
- Disconnect and reconnect your OneDrive account
- Check browser console for error messages
- Verify your site can make outbound HTTPS requests
Token Expired Message
The plugin automatically refreshes tokens. If you see this:
- Click Disconnect OneDrive
- Click Connect with OneDrive again
- Re-authorize the application
File Not Found
Causes:
- File deleted or moved
- Permission revoked
- Path changed
Solutions:
- Verify file exists in OneDrive
- Check sharing settings
- Re-attach file
Security Best Practices
Protect Your Credentials
- Never share your Client Secret publicly
- Don’t commit credentials to version control
- Use environment variables for sensitive data in development
Manage Access
- Regularly review connected applications in your Microsoft account
- Revoke access for applications you no longer use
- Set calendar reminders for secret expiration
- Minimize permissions:
- Use
Files.Readfor read-only - Use
Files.Read.Allfor shared files - Only add write permissions if needed
- Use
Revoke Access
To completely disconnect:
- In WordPress: Click Disconnect OneDrive in Downloads > Settings > OneDrive Connect > Azure AD App Configuration settings
- In Microsoft: Go to account.microsoft.com/privacy
- Find Apps and services and revoke access to your app
Azure App Settings Summary
For reference, here are all the Azure AD app settings:
Application Name: WPDM OneDrive (or custom)
Application Type: Web
Account Types: Multi-tenant + personal accounts (recommended)
Redirect URI: https://yoursite.com/onedrive-redirect
API Permissions (Delegated):
- Microsoft Graph: Files.Read
- Microsoft Graph: Files.Read.All
- Microsoft Graph: ReadWrite.All
- Microsoft Graph: ReadWrite
- Microsoft Graph: User.Read (optional)
- Microsoft Graph: offline_access (optional)
Client Secret: [Generated - expires in 24 months]
Personal vs Business
Personal OneDrive
| Feature | Availability |
|---|---|
| Storage | 5 GB free, up to 6 TB paid |
| Sharing | Public/specific people |
| Admin | Self-managed |
| Compliance | Basic |
OneDrive for Business
| Feature | Availability |
|---|---|
| Storage | 1 TB – unlimited |
| Sharing | Organization controls |
| Admin | IT managed |
| Compliance | Enterprise (DLP, eDiscovery) |
Tenant Configuration
For business/organization:
Tenant ID: your-org.onmicrosoft.com or Tenant ID: 87654321-dcba-hgfe-lkji-ba0987654321
For personal accounts:
Tenant ID: common or Tenant ID: consumers
Best Practices
- Use business accounts for enterprise features
- Regular token refresh – Access periodically
- Organize files – Clear folder structure
- Monitor storage – Watch quota usage
- Backup critical files – Don’t rely solely on OneDrive
- Review permissions – Audit app access regularly
Related Documentation
- Amazon S3 Integration
- Google Drive Integration
- Dropbox Integration
- File Attachments
- Get WPDM OneDrive add-on
Applies to: WordPress Download Manager 7.x + OneDrive Add-on