This guide provides the foundation for using the automation scripts and tools found in this repository. To interact with Google Chrome Enterprise services, you must first configure a Google Cloud project and establish a secure authentication method.
Before calling Premium APIs (like DLP events), verify the SKU assignment:
- Product ID:
101040 - Premium SKU ID:
1010400001
Before any script can run, the specific Google Cloud APIs must be enabled within your Google Cloud Project. This acts as the "on switch" for the services.
- Go to the Google Cloud Console.
- Select (or create) your project.
- Navigate to APIs & Services > Library.
- Search for and Enable the following APIs:
- Chrome Management API: For browser reporting, telemetry, and app management.
- Chrome Policy API: For managing browser policies programmatically.
- Admin SDK API: For managing Organizational Units (OUs) and Directory settings.
- Cloud Identity API: For provisioning and managing identity resources.
- Access Context Manager API: For setting attribute based access control to requests to Google Cloud services.
- Cloud Resource Manager API: Creates, reads, and updates metadata for Google Cloud Platform resource containers.
Scopes define the level of access a script has. The tools in the /Python folder typically require one or more of the following:
| Service | Scope URL |
|---|---|
| Chrome Management | https://www.googleapis.com/auth/chrome.management.appdetails.readonly, https://www.googleapis.com/auth/chrome.management.profiles, https://www.googleapis.com/auth/chrome.management.reports.readonly |
| Chrome Policy | https://www.googleapis.com/auth/chrome.management.policy, https://www.googleapis.com/auth/chrome.management.policy.readonly |
| Admin SDK | https://www.googleapis.com/auth/admin.directory.device.chromebrowsers, https://www.googleapis.com/auth/admin.directory.device.chromebrowsers.readonly, https://www.googleapis.com/auth/admin.directory.orgunit.readonly, https://www.googleapis.com/auth/admin.reports.audit.readonly |
| Cloud Identity API | https://www.googleapis.com/auth/cloud-identity.groups, https://cloudidentity.googleapis.com/v1/policies, https://cloudidentity.googleapis.com/v1beta1/policies, ``, |
| Access Context Manager API | https://accesscontextmanager.googleapis.com/v1,https://beyondcorp.googleapis.com/v1 |
Note: Always use the most restrictive scope possible (e.g., .readonly) if your script does not need to make changes.
We prioritize two methods that avoid the security overhead of Domain-Wide Delegation.
Best for: Local testing or manual scripts run by an administrator.
- In Cloud Console, go to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Select Desktop App.
- Download the
client_secrets.json. When you run a script, it will prompt you to log in via a browser to authorize the action.
Best for: Server-side automation, cron jobs, and CI/CD pipelines.
Step 1: Create the Service Account
- Go to IAM & Admin > Service Accounts.
- Click Create Service Account, name it, and click Done.
- Click the Service Account email > Keys > Add Key > Create new key (JSON).
- Download and save this key securely (never commit this to GitHub).
Step 2: Assign the Service Account to an Admin Role Instead of granting broad impersonation rights, we assign the service account email directly to a role in the Admin Console.
- Go to the Google Admin Console > Account > Admin roles.
- Create a Custom Role (e.g., "Chrome API Automator") and select the specific Chrome Management privileges required.
- Click Assign service accounts.
- Paste the Service Account Email address and click Add.
- Click Assign Role.
- 403 Forbidden: Ensure the API is enabled in the Cloud Project and the Service Account has been assigned the correct Role in the Admin Console.
- Insufficient Permissions: Verify the script is requesting the same scopes that were authorized during setup.
- Credential Security: If a Service Account key is ever accidentally shared or committed to code, delete it immediately in the Cloud Console and generate a new one.