Python tool to fetch Google Drive activity logs using the Drive Activity API.
- Install dependencies:
pip install -r requirements.txt-
Add
credentials.jsonfrom Google Cloud Console (OAuth 2.0 credentials with Drive Activity API enabled) -
First run will open browser for authentication
# Fetch all recent activities
python get_activity.py -o output.csv
# Fetch specific date range
python get_activity.py -o logs.csv --start 2024-10-01T00:00:00Z --end 2024-11-01T00:00:00Z# Poll every 30 seconds (default)
python get_activity.py -p
# Custom interval
python get_activity.py -p --poll-interval 60 --poll-output events.ndjson# No arguments launches GUI
python get_activity.py| Flag | Description |
|---|---|
-o FILE |
Output CSV file |
-p |
Enable polling mode |
--start TIME |
Start time (RFC3339: 2024-10-01T00:00:00Z) |
--end TIME |
End time (RFC3339) |
--poll-interval N |
Poll every N seconds (default: 30) |
--poll-output FILE |
NDJSON output file (default: drive_events.ndjson) |
--max-activities N |
Max activities to fetch (default: 20000) |
# Get last month's activity
python get_activity.py -o november.csv --start 2024-11-01T00:00:00Z --end 2024-12-01T00:00:00Z
# Monitor in real-time
python get_activity.py -p --poll-interval 10