Grant Service Account API Access
- Click the Navigation Menu in the upper-left corner of the page, and then select IAM & admin > Service Accounts.
- In the Domain-wide delegation column, click View Client ID.
- In the pop-up window, save the client ID for step 7.
- Go to https://admin.google.com and log into the same Google account.
- Scroll down and click on More Controls > Security.
- In Security, scroll down and select Advanced Settings.
- Click Manage API client access.
- In the Client Name field, enter the Client ID saved in Step 3. Your Client ID must be a string of numbers.
- In the One or More API Scopes field, enter:
"https://www.googleapis.com/auth/admin.directory.user,https://www.googleapis.com/auth/admin.reports.audit.readonly".
After getting your service account ID and JSON private key, grant the service account with Owner and Organization Administrator role for the projects to be monitored.