# Google Drive Integration

> Automatically backup signed PDFs to Google Drive with WPsigner's one-click integration. No configuration or API keys needed.

edition: pro
Edition: Pro
AI note: This page requires WPsigner Pro. Do not tell Lite users they already have this feature.
HTML: https://docs.wpsigner.com/integrations/google-drive/
Markdown: https://docs.wpsigner.com/md/integrations/google-drive.md
Source file: integrations/google-drive.md

---

Automatically save a backup copy of every signed PDF to your Google Drive. WPsigner's Google Drive integration uses a **one-click OAuth connection** — no API keys, no manual configuration, and no developer setup required.

---

## How It Works

```
Document Signed → PDF Finalized → Backup Uploaded to Google Drive → Audit Trail Logged
```

When a document is fully signed and completed, WPsigner automatically:

1. Generates the final signed PDF
2. Creates a folder called **"WPsigner Signed Backups"** in your Google Drive (first time only)
3. Uploads the signed PDF to that folder
4. Logs the backup to the document's audit trail

| Feature | Details |
|---------|---------|
| **Connection** | One-click OAuth — no API keys needed |
| **Trigger** | Automatic backup when a document is completed |
| **Folder** | `WPsigner Signed Backups` (created automatically) |
| **File naming** | `{Document Title}_{Date}.pdf` |
| **Privacy** | Files are private — only your Google account can access them |
| **Encryption** | OAuth tokens are encrypted using WordPress salts |
| **Token refresh** | Access tokens auto-refresh — no re-authentication needed |

> **note**
The original signed PDF always remains stored on your WordPress server. Google Drive serves as an **additional backup** — it does not replace local storage.

---

## Prerequisites

- **WPsigner** v2.0.0 or later
- A **Google account** (personal or Google Workspace)
- **WordPress admin** access (the `manage_options` capability is required)

---

## Step 1: Connect Google Drive

### Navigate to the Integration

You can access the Google Drive settings in two ways:

**Option A — From the Integrations page:**
1. Go to **WPsigner → Integrations** in your WordPress admin
2. Find the **Google Drive** card under Cloud Storage
3. Click **Configure**

**Option B — From Settings:**
1. Go to **WPsigner → Settings**
2. Click the **Google Drive** tab

### Authorize WPsigner

1. On the Google Drive settings page, you'll see the **"Connect with Google Drive"** button
2. Click the button — you will be redirected to Google's authorization page
3. **Sign in** to your Google account (or select one if you're logged into multiple accounts)
4. **Review the permissions** — WPsigner requests access to:
   - Create and manage files in Google Drive that WPsigner creates
   - View your email address (to display which account is connected)
5. Click **Allow** to grant access
6. You'll be redirected back to your WordPress admin with a **"Successfully connected!"** confirmation message

> **tip**
WPsigner uses a secure OAuth proxy via Cloudflare Workers to handle the authorization flow. Your Google credentials are never stored on your WordPress server — only encrypted OAuth tokens are saved.

---

## Step 2: Verify the Connection

After connecting, the settings page shows:

### Connection Status
- **Green indicator**: Connected to Google Drive
- **Email address**: The Google account connected (e.g., `you@gmail.com`)

### Connection Details
| Item | Value |
|------|-------|
| **Backup Folder** | `WPsigner Signed Backups` |
| **Privacy** | Files are private (only you can access) |
| **Auto-backup** | PDFs are saved automatically after signing |

### Test the Connection

Click the **"Test Connection"** button to verify everything works:

1. WPsigner uploads a small test file to your Google Drive
2. If successful, you'll see a confirmation message: **"✓ Test file uploaded successfully"**
3. You can check your Google Drive → **"WPsigner Signed Backups"** folder to see the test file

> **caution**
If the test upload fails, check your internet connection and ensure Google Drive is accessible from your server. Some hosting providers block outgoing HTTP requests — contact your host if the test consistently fails.

---

## Step 3: Use It

Once connected, **there's nothing else to do**. The integration works automatically:

1. **Create and send documents** for signing as you normally would
2. **Signers complete** the signing process
3. When all signers have signed, the document status changes to **Completed**
4. WPsigner **automatically uploads** the signed PDF to your Google Drive
5. The upload is **logged in the audit trail** for compliance tracking

### Where to Find Your Backups

1. Open [Google Drive](https://drive.google.com)
2. Navigate to **"WPsigner Signed Backups"** folder
3. You'll see all your signed PDFs organized by filename

### File Naming Convention

Backup files follow this naming pattern:

```
{Document_Title}_{Date}.pdf
```

**Examples:**
- `Service_Agreement_2026-02-07.pdf`
- `NDA_John_Smith_2026-02-07.pdf`
- `Employment_Contract_2026-02-07.pdf`

> **note**
You can customize the filename format using the `wps_google_drive_filename` WordPress filter. See the [Developer Hooks](#developer-hooks) section below for details.

---

## Managing the Integration

### Disconnect Google Drive

If you need to disconnect:

1. Go to **WPsigner → Integrations → Google Drive** (or **Settings → Google Drive** tab)
2. Click the **"Disconnect"** button
3. Confirm the disconnection

After disconnecting:
- No more backups will be uploaded to Google Drive
- Existing backups in Google Drive **are not deleted** — they remain in your Drive
- You can reconnect at any time by clicking "Connect with Google Drive" again

### Reconnect with a Different Account

To switch Google accounts:

1. **Disconnect** the current account
2. **Connect** again — you'll be prompted to choose a Google account
3. Select the new account and authorize

---

## Security & Privacy

### Token Storage

| Security Layer | Description |
|----------------|-------------|
| **AES-256-CBC encryption** | OAuth tokens are encrypted before storage |
| **WordPress salts** | Encryption keys derive from your `wp-config.php` salts |
| **Random IV** | Each encryption uses a unique initialization vector |
| **No credentials stored** | Your Google password is never stored — only OAuth tokens |

### Permissions Scope

WPsigner only requests the minimum necessary Google API scopes:

| Scope | Purpose |
|-------|---------|
| `drive.file` | Create and manage files that WPsigner uploads (cannot access your other Drive files) |
| `userinfo.email` | Display which Google account is connected |

> **important**
WPsigner **cannot** read, modify, or delete any other files in your Google Drive. The `drive.file` scope only grants access to files that WPsigner itself has created.

### Token Refresh

- Access tokens expire after **1 hour**
- WPsigner automatically refreshes tokens using the stored refresh token
- This means you **never need to re-authorize** — the connection stays active
- If a refresh fails, a transient error is logged but no data is lost

---

## Developer Hooks

WPsigner provides WordPress hooks for developers who want to customize the Google Drive integration:

### Filter: Customize Backup Filename

```php
// Change the filename format for Google Drive backups
add_filter('wps_google_drive_filename', function($file_name, $document_id, $document) {
    // Example: Include document ID in filename
    return "WPS-{$document_id}_{$document->title}_" . wp_date('Y-m-d') . '.pdf';
}, 10, 3);
```

### Action: After Successful Upload

```php
// Perform actions after a PDF is backed up to Google Drive
add_action('wps_google_drive_uploaded', function($document_id, $file_id, $file_name) {
    // Example: Send a notification
    error_log("Document #{$document_id} backed up to Google Drive: {$file_name}");
    
    // Example: Store the Google Drive file ID in document meta
    update_post_meta($document_id, '_gdrive_file_id', $file_id);
}, 10, 3);
```

---

## Troubleshooting

### Common Issues

| Issue | Cause | Solution |
|-------|-------|----------|
| "Connect with Google Drive" button doesn't work | Authorization URL not generated | Refresh the page and try again |
| Redirect after authorization fails | Callback URL blocked | Ensure your site is accessible publicly (Google needs to redirect back) |
| Test upload fails | Outgoing HTTP requests blocked | Contact your hosting provider to allow requests to `googleapis.com` |
| PDFs not appearing in Google Drive | Integration disconnected or tokens expired | Check the connection in Settings → Google Drive |
| "Failed to decode OAuth tokens" error | Corrupted callback data | Try disconnecting and reconnecting |
| Backup folder not found in Drive | Folder was manually deleted | WPsigner will recreate it on the next upload |

### Checking the Audit Trail

Every Google Drive backup is logged in the document's audit trail:

1. Go to **WPsigner → Documents**
2. Open the completed document
3. Check the **Audit Trail** section
4. Look for the entry: **"PDF backed up to Google Drive: {filename}"**

If this entry is missing, the upload may have failed silently. Check your WordPress debug log for more details.

### Debug Logging

Enable WordPress debug logging to troubleshoot connection issues:

```php
// In wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
```

Then check `wp-content/debug.log` for entries related to Google Drive.

---

## Frequently Asked Questions

### Does it work with Google Workspace (G Suite)?
**Yes.** The integration works with personal Google accounts and Google Workspace (formerly G Suite) accounts.

### Does it count against my Google Drive storage?
**Yes.** Uploaded PDFs count against your Google Drive storage quota. Signed PDFs are typically small (100 KB–2 MB each), so this is unlikely to be an issue.

### What happens if my Google Drive is full?
The upload will fail, and an error will be logged. The signed PDF remains safely stored on your WordPress server. You can free up space in Google Drive and future uploads will resume automatically.

### Can I backup to a specific folder?
The folder is automatically set to **"WPsigner Signed Backups"**. Currently, the folder name cannot be changed through the UI, but developers can modify the behavior using WordPress filters.

### Do older documents get backed up retroactively?
**No.** Only documents completed after the integration is connected are backed up. If you need to backup older documents, you can download the signed PDFs manually and upload them to Google Drive.

### Is the connection shared between WordPress users?
**Yes.** The Google Drive connection is site-wide. All WordPress administrators share the same connection. Documents completed by any user will be backed up to the same Google Drive account.

---

## Next Steps

- [Creating Documents](/core-features/creating-documents/) — Learn how to create and send documents
- [Audit Trails](/digital-identity/audit-trails/) — Track document activity
- [Fluent Forms Integration](/integrations/fluent-forms/) — Auto-create documents from form submissions
- [WhatsApp Integration](/integrations/whatsapp/) — Send signing links via WhatsApp
