Setup
Connect to Google Drive
Required permissions for setup
The user setting up this data source must be a Google Super Admin.
Set up custom admin role (optional)
To use the Google Drive API, the Glean service account needs to impersonate a user with certain privileges via domain-wide delegation. This can be the Super Admin performing this setup, or a custom admin role can be created with the required privileges and assigned to a different Google Workspace user (this can be an existing user, or a new user created for this purpose).
If you would like to use the Super Admin account, simply enter the email of the Super Admin into the Directory admin email field in Glean. Otherwise, to create a custom admin role:
- Go to https://admin.google.com/ac/roles. Click Create new role. Name the role Glean. Click Continue.
- Under Admin Console Privileges, select the following:
- Organization Units > Read
- Users > Read
- Services > Drive and Docs > Settings
- Domain Settings**
- Under Admin API Privileges, select the following:
- Organization Units > Read
- Users > Read
- Groups > Read
- Reports*
- Domain Management**
- Click Continue, and then Create Role.
- You should be redirected to a page where you can assign users to the Glean role you just created. Click Assign members, and add a Google Workspace user. This user needs to have logged in at least once to the Google Workspace and accepted the Terms of Service. Click Assign role.
- Enter the email of the user from the previous step into the Directory admin email field in Glean.
Add API scopes
-
Go to the Domain-wide Delegation section in Google Admin Console. You’ll need to be signed in as an admin.
-
Click Add new and paste the 21-digit Unique ID from Glean into the Client ID field. You can find this in the setup instructions in your Glean Admin Console.
Note: if you have already connected Google Tools (Google Calendar and Gmail) with this same Client ID, you should instead click ‘Edit’ on the existing API client and then add the additional scopes below.
-
Copy and paste the following into the OAuth scopes (comma-delimited) field and then click Authorize:
Notes:
- The scope
https://www.googleapis.com/auth/admin.directory.domain.readonlyis to optionally read configured domains - The scope
https://www.googleapis.com/auth/drive.admin.labels.readonlyis for optional labels crawling - The scope
https://www.googleapis.com/auth/calendar.readonlyis optional at this step, but necessary if you want to set up Google Calendar

- The scope
Add additional Google Drive domains
Glean will automatically crawl all users and documents in the domain belonging to the directory admin email. If there are users registered to other domains within the Google Workspace, those domains need to be specified. To include additional domains from your Google Workspace account, follow these steps:
(Recommended) Fetch additional domains from your Google Workspace account.
- Ensure the previous steps were followed:
2. In the admin role you created, add the following under Admin Console
Privileges:
- Domain Settings
- Additionally, add the following under Admin API Privileges:
- Domain Management
- In the API client you created, add the following to the OAuth scopes (comma-delimited) field:
- Click Retrieve domains in Glean to fetch the domains in your Google Workspace account. You can then select the domains you want to include in Glean.
(Alternative) Manually add additional domains
Visit the Manage Domains page in Google Admin Console to see the full list
of all of the domains within the Google Workspace instance. Enter the domains you want to include into the text box in
Glean, separated by commas, without any additional spaces.
For example: example.com,example.org.
Configure target audience mapping
If your Google Drive uses target audiences to restrict document access, you can provide a mapping from audience IDs to Google Groups. This allows Glean to properly understand which users should have access to documents with specific target audiences.
- Download the CSV template by clicking the download button in the Target audience mapping section.
- Check if target audiences are configured:
- Go to Google Admin Console > Apps > Google Workspace > Drive and Docs
- Navigate to Sharing settings > Target audience
- If there are any target audience configured, you will need to identify the ids of the configured audiences. Remember these audience names as you'll need to look these up.
- If no target audiences are specified, you can skip the remainder of these steps.
- Find the target audience ID
- Go to Google Admin Console > Directory > Target Audiences
- For each of the target audiences referenced in the previous step, click on each audience to navigate to that specific audience page.
- Copy the audience ID. This should be the suffix of the audience page url (e.g.
audience-idfrom the page https://admin.google.com/ac/targetaudiences/audience-id).
- Fill out the CSV file with the following format:
- Column 1: Audience ID
- Column 2: Corresponding Google Group email address
Example:
xyz123,engineering@yourcompany.com abc456,marketing@yourcompany.com
- Upload the completed CSV file using the file upload field in Glean.
Finally, click Save in Glean. You're all set!