In the Google Admin console, Reporting → Audit and investigation holds the logs (Login, Admin, Drive, OAuth and more), and each can be exported from there. For JSON, use the Admin SDK Reports API, method activities.list. For a one-off, you don’t even need code: the API reference page has a “Try this method” panel that runs the call as you. Most Workspace audit data is kept for six months.
Workspace audit logs show who signed in from where, which third-party apps got access to mail and files, and which documents were suddenly shared with the outside world. Prime Core has {N} detection rules for Google Workspace data, mapped to {M} MITRE ATT&CK techniques. Among them: abuse of cloud accounts (T1078.004), malicious OAuth grants (T1528) and mail forwarding to outside addresses (T1114.003).
Before you start
Permissions. A super admin, or an admin role with the Reports privilege.
Pick the right log. In the API, each log is an applicationName: login, admin, drive, token (OAuth grants), user_accounts, saml, groups and others. Gmail message logs aren’t part of this API. For those, use Email Log Search in the Admin console, or the BigQuery export if your edition has it.
Retention and lag. Most audit logs go back about six months. New events can take from minutes to hours to show up, depending on the log.
A short Python script
For repeatable exports, a service account with domain-wide delegation impersonates an admin. It needs google-api-python-client and google-auth:
import json
from google.oauth2 import service_account
from googleapiclient.discovery import build
creds = service_account.Credentials.from_service_account_file(
"sa.json",
scopes=["https://www.googleapis.com/auth/admin.reports.audit.readonly"],
subject="admin@example.com",
)
svc = build("admin", "reports_v1", credentials=creds)
with open("workspace_login_1019.jsonl", "w") as out:
req = svc.activities().list(
userKey="all", applicationName="login",
startTime="2026-10-19T00:00:00Z", endTime="2026-10-20T00:00:00Z",
maxResults=1000,
)
while req is not None:
resp = req.execute()
for item in resp.get("items", []):
out.write(json.dumps(item) + "\n")
req = svc.activities().list_next(req, resp)
Domain-wide delegation is powerful. Grant it only this read-only scope, keep the key file out of shared drives, and remove the delegation when you’re done. Run the script once per applicationName you need.
What to look for
| Log and event | Why it matters |
|---|---|
| login: bursts of login_failure, any suspicious_login | Password guessing, or Google itself flagging a sign-in |
| token: authorize | A third-party app was granted scopes; check what it can read |
| admin: role assignments, user creation, 2-Step Verification policy changes | Privilege changes and weakened security settings |
| drive: access or visibility changes to external or “anyone with the link” | Data being opened up to the outside |
| user_accounts: 2SV disabled, password changed | Account takeover cleanup, or preparation |
Upload, sanitize and review in LogTotal
- Upload. Open logtotal.com and drop in the .jsonl file.
- Sanitize.
- Review.
When it goes wrong
| Symptom | Likely cause | Fix |
|---|---|---|
| 403 or insufficient permissions | Admin lacks the Reports privilege, or the delegated scope isn’t authorized | Check the admin role; check the domain-wide delegation entry |
| Empty results | Wrong applicationName, events too recent, or beyond retention | Check the name; wait; check the dates |
| Stops at 1,000 events | Paging not followed | Use pageToken or list_next |
| No Gmail message events | Not part of the Reports API | Use Email Log Search or BigQuery |
FAQ
Can I get these logs through Google Cloud instead?
If your organization shares Workspace data with Google Cloud, the audit logs appear in Cloud Logging at the organization level, and our [Google Cloud audit log guide] applies.
Isn’t the alert center enough?
The alert center shows what Google decided to flag. The audit logs show everything, including what wasn’t flagged.