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:
- Uploading your Office document to Google Drive
- Exporting it as PDF using Google's native conversion
- 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¶
- Go to Google Cloud Console
- Click Select a project → New Project
- Enter a project name (e.g.,
pdf-converter) - Click Create
Step 2: Enable the Google Drive API¶
- In your project, go to APIs & Services → Library
- Search for Google Drive API
- Click on it and press Enable
Step 3: Create a Service Account¶
- Go to APIs & Services → Credentials
- Click Create Credentials → Service Account
- Fill in the details:
- Service account name:
pdf-converter-sa - Service account ID: Auto-generated (e.g.,
pdf-converter-sa@your-project.iam.gserviceaccount.com) - Description: Service account for PDF conversion
- Click Create and Continue
- Skip role assignment (not needed for Drive API with personal use)
- Click Done
Step 4: Generate JSON Key File¶
- In the Service Accounts list, click on your newly created service account
- Go to the Keys tab
- Click Add Key → Create New Key
- Select JSON format
- Click Create
- 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¶
Option 1: Environment Variable (Recommended)¶
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¶
-
Never commit the JSON file to version control
-
Add to
.gitignore:
*.json
.env
-
Use environment variables or a secrets manager
-
Rotate keys periodically by creating new service accounts
-
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
Related¶
- Supported Providers - Overview of all providers
- Configuration - Environment variables reference
- Troubleshooting - Common issues and solutions