Setting up Google Drive Integration
This guide explains how to set up the Google Drive integration for DocuElevate.
Required Configuration Parameters
| Variable | Description |
|---|---|
GOOGLE_DRIVE_USE_OAUTH |
Set to true to use OAuth flow (recommended) |
GOOGLE_DRIVE_CLIENT_ID |
OAuth Client ID (required if using OAuth flow) |
GOOGLE_DRIVE_CLIENT_SECRET |
OAuth Client Secret (required if using OAuth flow) |
GOOGLE_DRIVE_REFRESH_TOKEN |
OAuth Refresh Token (required if using OAuth flow) |
GOOGLE_DRIVE_FOLDER_ID |
Google Drive folder ID for file uploads |
GOOGLE_DRIVE_CREDENTIALS_JSON |
JSON string containing service account credentials (alternative method) |
GOOGLE_DRIVE_DELEGATE_TO |
Email address to delegate permissions (optional for service accounts) |
For a complete list of configuration options, see the Configuration Guide.
Authentication Methods and Setup Flows
DocuElevate supports two authentication methods for Google Drive:
- OAuth Authentication (Recommended) - User-based authentication that provides better security and control. Recommended for most deployments.
- Service Account Authentication - Server-to-server authentication that doesn't require user interaction. Useful for specific enterprise deployments.
Per-User OAuth Flow (Integrations Dashboard)
End users can authorize their own Google Drive integration directly from the Integrations dashboard — no admin involvement required:
- Navigate to
/integrationsand click + Add Destination (or + Add Source for Watch Folder). - Create a Google Drive destination integration (or a Watch Folder with
source_type = google_drive). - Click the Authorize button — it opens the OAuth wizard pre-loaded with your integration's configuration.
- If the administrator has configured system-wide Google Drive app credentials (
GOOGLE_DRIVE_CLIENT_ID/GOOGLE_DRIVE_CLIENT_SECRET), the wizard defaults to using them — no need to register your own Google Cloud app. Uncheck the toggle to use custom credentials if needed. - Click Start Authentication Flow and authorize access in Google.
- Credentials are saved automatically to your personal integration record; the page redirects back to
/integrations. - Re-authorization is available at any time via the Re-Authorize button.
Note: Credentials are stored encrypted per-integration. Each user can hold multiple Google Drive integrations with independent tokens targeting different folders or accounts.
Method 1: OAuth Authentication Setup (System-Level)
The OAuth method is preferred as it: - Provides better security with token expiration and refresh - Integrates with personal Google accounts more seamlessly - Doesn't require manual folder sharing - Offers a streamlined setup process with our setup wizard
1. Create a Google Cloud Project
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Navigate to "APIs & Services" > "Library"
- Search for and enable the "Google Drive API"
2. Configure OAuth Consent Screen
- In "APIs & Services", go to "OAuth consent screen"
- Select "External" user type (or "Internal" if this is for an organization)
- Fill out the required application information:
- App name: "DocuElevate" (or your preferred name)
- User support email: Your email
- Application homepage link: Your application URL
- Authorized domains: Your domain
- Developer contact information: Your email
- Click "Save and Continue"
- On the Scopes screen, click "Add or Remove Scopes" and add:
https://www.googleapis.com/auth/drive.file(allows access to files created or opened by the app)- Click "Save and Continue" through the rest of the setup
3. Create OAuth Credentials
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Select "Web application" for Application type
- Add a name (e.g., "DocuElevate Web Client")
- Under "Authorized JavaScript origins" add your application URL (e.g.,
https://your-docuelevate-instance.com) - Under "Authorized redirect URIs" add:
https://your-docuelevate-instance.com/google-drive-callback- Click "Create"
- Note down your Client ID and Client Secret
4. Use the OAuth Setup Wizard
DocuElevate includes a built-in OAuth setup wizard that makes configuration simple:
- Go to your DocuElevate instance and navigate to Settings > Google Drive Setup
- Select the OAuth method tab (selected by default)
- Enter your Client ID and Client Secret
- Click "Start Authentication Flow"
- Follow the prompts to authenticate and select a folder
- The wizard will automatically save your settings and generate the required environment variables
5. Manual OAuth Configuration
If you prefer to set up OAuth manually, you'll need to:
- Set
GOOGLE_DRIVE_USE_OAUTH=truein your configuration - Set
GOOGLE_DRIVE_CLIENT_IDandGOOGLE_DRIVE_CLIENT_SECRETfrom the credentials you created - Obtain a refresh token using OAuth2 authorization flow (outside the scope of this document)
- Set
GOOGLE_DRIVE_REFRESH_TOKENwith the obtained refresh token - Set
GOOGLE_DRIVE_FOLDER_IDto your desired folder ID
OAuth Token Expiration Notice
When using the OAuth method with Google Drive, there are important limitations to be aware of:
Non-Verified Apps
If your Google Cloud project is not verified by Google (displayed as "unverified" during the OAuth consent screen):
- Refresh tokens expire after 7 days for test/development applications
- You will need to re-authenticate every 7 days
- The application will show "This app isn't verified" warning during authentication
This limitation primarily affects development environments. For production use, you should:
- Complete the Google OAuth verification process
- Submit your app for verification in the Google Cloud Console
- Provide the required information including privacy policy and application testing instructions
Verified Apps
Once your app is verified by Google:
- Refresh tokens remain valid until explicitly revoked
- Users won't see the "unverified app" warning
- You can request access to more sensitive scopes
For internal applications within your organization, consider using the Service Account method instead, which doesn't have the 7-day token expiration limitation.
Folder Selection
DocuElevate provides two ways to select your Google Drive destination folder:
1. Web Interface Folder Picker
The DocuElevate web interface includes an integrated Google Drive folder picker that allows you to:
- Browse your Google Drive folders visually
- Select the destination folder through a user-friendly interface
- Automatically save the selected folder ID to your configuration
To use the folder picker:
- Complete the OAuth authentication flow
- On the Google Drive setup page, click the "Select Folder with Picker" button
- Browse and select your desired folder in the popup window
- The folder ID will be automatically filled in and saved
2. Manual Folder ID Entry
You can also manually specify the folder ID:
- Navigate to the desired folder in Google Drive
- Extract the folder ID from the URL:
https://drive.google.com/drive/folders/YOUR_FOLDER_ID - Enter this ID in the "Folder ID" field in the DocuElevate setup page
For the root folder of your Google Drive, use root as the folder ID.
Note: The folder selector requires that you've already authenticated with OAuth. It's not available when using the Service Account method, as it requires user interaction.
Method 2: Service Account Setup (Alternative)
Service accounts are useful for specific enterprise deployments where interactive login is not possible or when you need to access shared drives with domain-wide delegation.
1. Create a Google Cloud Project
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Navigate to "APIs & Services" > "Library"
- Search for and enable the "Google Drive API"
2. Create Service Account
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "Service Account"
- Fill in the service account details and click "Create"
- Add appropriate roles (e.g., "Editor" for full access)
- Click "Continue" and then "Done"
- Note down the service account's email address (it will look like:
service-name@project-id.iam.gserviceaccount.com)
3. Generate Service Account Key
- Find your service account in the list and click on it
- Go to the "Keys" tab
- Click "Add Key" > "Create New Key"
- Choose JSON format and click "Create"
- The key file will be downloaded automatically
4. Share Your Google Drive Folder with the Service Account
- Navigate to the desired folder in Google Drive
- Right-click on the folder and select "Share"
- Enter the service account's email address that you noted down in step 2
- Set the permission to "Editor" (to allow the service account to create/upload files)
- Click "Send" to share the folder (you can uncheck "Notify people" as the service account won't receive emails)
5. Get Google Drive Folder ID
To find your Google Drive folder ID:
- Navigate to the desired folder in Google Drive web interface
- The URL will look like:
https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i0j - The string after "folders/" is your folder ID (in this example:
1a2b3c4d5e6f7g8h9i0j) - Set this value as
GOOGLE_DRIVE_FOLDER_IDin your configuration
6. Configure DocuElevate
- Open the downloaded JSON key file
- Set the entire JSON content as the
GOOGLE_DRIVE_CREDENTIALS_JSONenvironment variable - For security, ensure the JSON is properly escaped if your deployment method requires it
- Make sure
GOOGLE_DRIVE_USE_OAUTHis set tofalse
Domain-Wide Delegation (Optional, for Service Accounts)
If you need the service account to access files on behalf of users in your Google Workspace:
- In your Google Workspace Admin Console, go to:
- Security > API Controls > Domain-wide Delegation
- Click "Add new" and provide:
- Client ID: your service account's client ID (found in the JSON credentials file)
- OAuth Scopes:
https://www.googleapis.com/auth/drive - Set
GOOGLE_DRIVE_DELEGATE_TOto the email address of the user to impersonate
This setup is only relevant for Google Workspace environments where you need the service account to access user-specific files.
Troubleshooting
Authentication Issues
- Error: "The caller does not have permission"
- For OAuth: Make sure you're signed in with an account that has access to the folder
- For Service Account: Ensure you've properly shared the target folder with the service account email
-
Check that you've enabled the Google Drive API in your project
-
Error: "Invalid credentials"
- For OAuth: Your tokens may have expired. Try refreshing authentication in the setup wizard
- For Service Account: Verify that your JSON credentials are properly formatted and not corrupted
-
Check that the account has not been deleted or disabled
-
OAuth Errors
- Ensure your redirect URIs exactly match your application URL
- Check that you've added the correct scopes
- Make sure your OAuth consent screen is properly configured
File Upload Issues
- Error: "File not found"
- Verify your folder ID is correct
-
Make sure the folder still exists and hasn't been deleted
-
Error: "Insufficient permissions"
- For OAuth: Ensure you've granted the necessary permissions during authorization
- For Service Account: Ensure the service account has "Editor" permissions on the folder
Testing Your Setup
To test if your Google Drive integration is working:
- Go to your DocuElevate instance and navigate to Settings > Google Drive Setup
- Click the "Test Connection" button
- If the test is successful, your integration is properly configured
For further assistance, see the Troubleshooting Guide.