Google Admin API
| title | description | updated_date |
|---|---|---|
| Google Admin API | How to generate an API token for the Google Admin SDK. | 2025-10-24T16:45:21Z |
What we need
[] Google Credentials [] Domain [] Username Admin
Follow these steps to create credentials for the Google Admin API:
Create or select a Google Cloud project
- Go to the Google Cloud Console.
- Select an existing project or click New Project.
Enable Google APIs
- Navigate to
API & Services>Enabled API & Services - For each of the following available
APIs & Services, find the API and navigate to the page and click Enable if it is not already enabled.- GMail API
- Google Slides API
- Google Sheets API
- Google Drive API
- Google Docs API
- Google Calendar API
- Google Drive Activity API
- Admin SDK API
- Google Meet REST API
⚠️ IMPORTANT: Make sure ALL these APIs are enabled. Failure to enable any of these APIs will result in permission errors when trying to access the corresponding Google services.
Common Error: If you encounter the error
Drive Activity API has not been used in project [PROJECT_ID] before or it is disabled, this means the Drive Activity API specifically needs to be enabled. Navigate to the provided URL in the error message or go toAPI & Services>Library, search for “Drive Activity API”, and click Enable.- Navigate to
Enable the Admin SDK API
- In the Cloud Console, navigate to APIs & Services > Library.
- Search for Admin SDK and click Enable.
Create a service account
- Go to APIs & Services > Credentials.
- Click Create Credentials > Service Account.
- Enter a name and description, then click Create.
Grant the service account proper roles
- Assign roles like Owner or more restrictive roles as needed.
- Click Done.
Generate a service account key
- In the Service Accounts list, locate your service account and click Manage keys.
- Click Add Key > Create new key.
- Choose JSON and click Create. A JSON file will be downloaded.
Configure Domain-Wide Delegation (CRITICAL) (see also official docs)
Go to your Google Workspace Admin Console as a Super Administrator.
Navigate to Security > Access and data control > API controls.
Look for Manage Domain-wide Delegation and click on it.
Click Add new to add a new API client.
For the Client ID, enter the Client ID of your service account (found in the service account details page or in the downloaded JSON file as
client_id).For OAuth Scopes, add the following scopes (one per line):
https://www.googleapis.com/auth/admin.directory.user.readonlyhttps://www.googleapis.com/auth/admin.directory.group.readonlyhttps://www.googleapis.com/auth/directory.readonlyhttps://www.googleapis.com/auth/drive.activity.readonlyhttps://www.googleapis.com/auth/drive.readonlyhttps://www.googleapis.com/auth/drive.metadata.readonlyhttps://www.googleapis.com/auth/documents.readonlyhttps://www.googleapis.com/auth/spreadsheets.readonlyhttps://www.googleapis.com/auth/presentations.readonlyhttps://www.googleapis.com/auth/calendar.readonlyhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/userinfo.profilehttps://www.googleapis.com/auth/userinfo.emailhttps://www.googleapis.com/auth/meetings.space.readonlyhttps://www.googleapis.com/auth/drive.meet.readonly
Click Authorize.
Important Note: The “unauthorized_client” error occurs when Domain-Wide Delegation is not properly configured. This step is essential for the service account to access user data through the Admin API.
Troubleshooting Common API Errors:
- Drive Activity API Error: If you see
Drive Activity API has not been used in project [PROJECT_ID] before or it is disabled, go to the Google Cloud Console, navigate toAPI & Services>Library, search for “Google Drive Activity API”, and click Enable. Wait a few minutes for the change to propagate. - Other API Permission Errors: Similar errors can occur for any of the APIs listed in step 2. Always ensure ALL required APIs are enabled in your Google Cloud project.
Troubleshooting: If you encounter issues with the Google Admin API, please refer to our troubleshooting guide.
Finding Your Service Account Client ID
The Client ID is a long string that looks like: 123456789012-abcdefghijklmnopqrstuvwxyz123456.apps.googleusercontent.com
You can find it:
- In your Google Cloud Console under APIs & Services > Credentials > Service Accounts
- Click on your service account, then look for “Unique ID” or “Client ID”
- Or in the downloaded JSON credentials file as the
client_idfield
Required OAuth Scopes
For most user operations, you’ll need these scopes:
| Operation | Required Scope |
|---|---|
| Reading users | https://www.googleapis.com/auth/admin.directory.user.readonly |
| Reading groups | https://www.googleapis.com/auth/admin.directory.group.readonly |
| Reading all directory information (users, groups, organizational units, etc.) | https://www.googleapis.com/auth/directory.readonly |
| Reading Drive file activity | https://www.googleapis.com/auth/drive.activity.readonly |
| Reading all Drive files and metadata | https://www.googleapis.com/auth/drive.readonly |
| Reading Drive file metadata | https://www.googleapis.com/auth/drive.metadata.readonly |
| Reading Google Docs documents | https://www.googleapis.com/auth/documents.readonly |
| Reading Google Sheets spreadsheets | https://www.googleapis.com/auth/spreadsheets.readonly |
| Reading Google Slides presentations | https://www.googleapis.com/auth/presentations.readonly |
| Reading Google Calendar events and settings | https://www.googleapis.com/auth/calendar.readonly |
| Reading Gmail messages and settings | https://www.googleapis.com/auth/gmail.readonly |
| Reading user profile information (name, profile picture) | https://www.googleapis.com/auth/userinfo.profile |
| Reading user’s email address | https://www.googleapis.com/auth/userinfo.email |
| Reading user’s Google Drive files created by Google Meet | https://www.googleapis.com/auth/drive.meet.readonly |
| Read user’s Google Meet information | https://www.googleapis.com/auth/meetings.space.readonly |
You can now call the Admin SDK from your client using these credentials.
Item Checklist of what’s needed for integration
- The credentials json created above
- The Domain of the Google Organization (it’s the part after “@” in company emails)
- One admin email address (must be a Super Admin with access to configure API controls)