Prerequisites
- Google Cloud project with the Google Drive API enabled
- Service account with access to a shared Drive folder
Setup
Option 1: Interactive CLI
Option 2: Environment variables
Add to your.env:
| Variable | Default | Description |
|---|---|---|
GOOGLE_CREDENTIALS_FILE | — | Required. Path to the service account JSON file |
GOOGLE_DRIVE_FOLDER_ID | — | Required. Google Drive folder ID for investigation reports |
Option 3: Persistent store
Creating a service account
- In Google Cloud Console, go to IAM & Admin → Service Accounts
- Click Create Service Account
- Give it a name (e.g.,
opensre-docs) and click Create - Skip role assignment and click Done
- Click on the service account → Keys → Add Key → Create new key (JSON)
- Download the JSON file
Granting Drive folder access
- In Google Drive, open the folder where reports should be saved
- Click Share
- Add the service account email (e.g.,
opensre-docs@your-project.iam.gserviceaccount.com) - Set the permission to Editor
Finding the folder ID
The folder ID appears in the Drive URL:https://drive.google.com/drive/folders/<folder-id>
Verify
Troubleshooting
| Symptom | Fix |
|---|---|
| Credentials file not found | Check the path in GOOGLE_CREDENTIALS_FILE — use an absolute path |
| 403 Forbidden | The service account hasn’t been added to the Drive folder with Editor access |
| Drive API not enabled | Enable the Google Drive API in your Google Cloud project |
| Folder not found | Confirm the folder ID and that the service account has access |
Security best practices
- Keep the service account JSON file outside of your repository — add it to
.gitignore. - Grant the service account access only to the specific Drive folder it needs.
- Rotate the service account key periodically via Google Cloud Console.