Skip to content
Edit this page View source of this page

Google Drive setup

Google Drive Setup

Google Drive provides unlimited conversions by leveraging Google Docs/Sheets/Slides to convert Office documents to PDF. This guide shows you how to set up a Google Cloud Service Account and obtain the required JSON credentials file.

Overview

The Google Drive provider works by:

  1. Uploading your Office document to Google Drive
  2. Exporting it as PDF using Google's native conversion
  3. Deleting the temporary file from Drive

No browser interaction required — everything is automated via the Google Drive API.

Prerequisites

  • A Google account (personal or work)
  • Access to Google Cloud Console

Step 1: Create a Google Cloud Project

  1. Go to Google Cloud Console
  2. Click Select a project → New Project
  3. Enter a project name (e.g., pdf-converter)
  4. Click Create

Step 2: Enable the Google Drive API

  1. In your project, go to APIs & Services → Library
  2. Search for Google Drive API
  3. Click on it and press Enable

Step 3: Create a Service Account

  1. Go to APIs & Services → Credentials
  2. Click Create Credentials → Service Account
  3. Fill in the details:
  4. Service account name: pdf-converter-sa
  5. Service account ID: Auto-generated (e.g., pdf-converter-sa@your-project.iam.gserviceaccount.com)
  6. Description: Service account for PDF conversion
  7. Click Create and Continue
  8. Skip role assignment (not needed for Drive API with personal use)
  9. Click Done

Step 4: Generate JSON Key File

  1. In the Service Accounts list, click on your newly created service account
  2. Go to the Keys tab
  3. Click Add Key → Create New Key
  4. Select JSON format
  5. Click Create
  6. The JSON file will download automatically (e.g., your-project-abc123.json)

⚠️ Important: Keep this file secure! It contains your private key and should never be committed to version control.

Step 5: Configure the Provider

export GOOGLE_DRIVE_CREDENTIALS=/path/to/your/service_account.json

Option 2: Command Line

pdf-remote-converter convert --provider google_drive input.docx output.pdf

The provider will automatically look for the GOOGLE_DRIVE_CREDENTIALS environment variable.

Step 6: Test the Setup

pdf-remote-converter convert --provider google_drive test.docx test.pdf --verbose

You should see output like:

[INFO] pdf_remote_converter.providers.google_drive: Uploaded test.docx to Google Drive as file ID 1a2b3c4d5e6f
[INFO] pdf_remote_converter.providers.google_drive: Exported Google Drive file 1a2b3c4d5e6f as PDF (12345 bytes)
[INFO] pdf_remote_converter.providers.google_drive: Deleted Google Drive file 1a2b3c4d5e6f

Troubleshooting

Error: "Google Drive credentials file not found"

Solution: Verify the path is correct:

ls -la /path/to/your/service_account.json

Error: "Google Drive authentication failed"

Solution: Ensure the JSON file is valid:

cat /path/to/your/service_account.json | python -m json.tool

Error: "Google Drive access denied"

Solution: Verify the Drive API is enabled in your Google Cloud project.

Error: "Google Drive rate limit exceeded"

Solution: Google Drive has rate limits. Wait a few minutes and retry, or use a different provider.

Security Best Practices

  1. Never commit the JSON file to version control

  2. Add to .gitignore:

*.json
.env
  1. Use environment variables or a secrets manager

  2. Rotate keys periodically by creating new service accounts

  3. Restrict API access to only the Drive API scope

Quota and Limits

  • Conversions: Effectively unlimited for personal use
  • File Size: Up to 5 TB (Google Drive limit)
  • Rate Limits: Google Drive API has per-user rate limits (typically 100-1000 requests/100 seconds)
  • Storage: Temporary files are automatically deleted after conversion