IntermediateIdentity Provider15 min read

Connect GCP Cloud Identity to Gateco

Connect GCP Cloud Identity to Gateco using Admin SDK domain-wide delegation. Covers service account setup, DWD OAuth scopes, and automated group sync.

Last updated: May 21, 2026

Prerequisites

  • A GCP project with billing enabled
  • Permission to create service accounts and assign IAM roles
  • A Google Workspace or Cloud Identity domain
  • Super-admin access to the Google Admin console (admin.google.com)

Overview — 6 steps

  1. 1Enable the Admin SDK API
  2. 2Create a service account
  3. 3Download the service account key
  4. 4Enable domain-wide delegation
  5. 5Authorize delegation in Google Admin console
  6. 6Add credentials to Gateco

Gateco connects to Google Workspace or Cloud Identity via the Google Admin SDK using domain-wide delegation (DWD). DWD allows a GCP service account to impersonate a domain super-admin and read users and groups from your directory for identity-aware retrieval. This guide walks through both the GCP Console setup and the Google Admin console authorization needed to enable RAG access control based on your Google Workspace groups.

GCP Cloud Identity integration requires the Growth plan or above. Admin SDK API calls are free within your Google Workspace subscription.

Step 1 — Enable the Admin SDK API

  1. Open GCP Console → APIs & Services → Library.
  2. Search for "Admin SDK API" and click Enable.
  3. The API is called admin.googleapis.com in CLI contexts.
bash
# Alternative: enable via gcloud CLI
gcloud services enable admin.googleapis.com --project=YOUR_PROJECT_ID

Step 2 — Create a service account

  1. Go to IAM & Admin → Service Accounts → Create service account.
  2. Name: gateco. Click Create and continue.
  3. Grant the role: roles/iam.serviceAccountTokenCreator (required for DWD token issuance).
  4. Click Done.

Step 3 — Download the service account key

  1. Click into the service account you just created.
  2. Go to Keys → Add key → Create new key → JSON.
  3. Save the downloaded file securely.
  4. Convert the JSON key to single-line format for use in environment variables.
bash
python3 -c "import json, sys; print(json.dumps(json.load(open('path/to/key.json'))))"

GCP_SERVICE_ACCOUNT_JSON must be valid JSON on a single line. Newlines inside the private_key field must remain as \n escape sequences, not literal newlines. Use the command above to ensure correct formatting.

Step 4 — Enable domain-wide delegation

Back in GCP Console:

  1. Go to IAM & Admin → Service Accounts and click into your service account.
  2. Click Edit (pencil icon).
  3. Check "Enable Google Workspace domain-wide delegation".
  4. Click Save.
  5. Note the Unique ID shown on the service account page (a long number, e.g. 103675186029495848977). You will use this in Step 5.

Step 5 — Authorize delegation in Google Admin console

  1. Open Google Admin console at admin.google.com.
  2. Navigate to Security → Access and data control → API controls.
  3. Click Manage domain-wide delegation → Add new.
  4. Enter the service account Unique ID from Step 4 in the Client ID field.
  5. Add all three OAuth scopes (comma-separated) from the box below.
  6. Click Authorize.
text
https://www.googleapis.com/auth/admin.directory.user.readonly,
https://www.googleapis.com/auth/admin.directory.group.readonly,
https://www.googleapis.com/auth/admin.directory.group.member.readonly

These three scopes are read-only. Gateco only reads users and groups — it never modifies your directory.

Step 6 — Add credentials to Gateco

  1. Navigate to Identity Providers → Add provider → GCP Cloud Identity.
  2. Enter the values from the table below.
  3. Click Test connection.
  4. Click Save.
FieldValue
DomainYour Google Workspace primary domain (e.g. yourcompany.com)
Admin EmailSuper-admin email to impersonate (e.g. admin@yourcompany.com)
Service Account JSONThe single-line JSON from Step 3

How Gateco uses your Cloud Identity data

Cloud Identity fieldGateco principal fieldUse in policy conditions
primaryEmailemailprincipal.email
name.givenName + familyNamedisplay_nameDisplay only
organizations[0].departmentattributes.departmentprincipal.attributes.department
Group membershipgroups arrayprincipal.groups

Policy conditions reference the group name without the domain (e.g. "engineering", not "engineering@yourcompany.com"). The adapter strips the domain suffix. The department field reads from organizations[0].department — set it under Employee information in the Google Admin console user profile.

Troubleshooting

ErrorCauseFix
403: Not Authorized to access this resourceDWD not authorized in Google Admin consoleGo to admin.google.com → Security → API controls → DWD and verify all three scopes are present for the correct Client ID
0 users returned after successful connectionGCP_DOMAIN does not match primary Workspace domainCheck Admin console → Account → Account settings → Profile for the correct primary domain
department attribute empty on synced principalsDepartment set in wrong profile sectionSet department under User profile → Employee information → Department (not under custom attributes)
GCP_SERVICE_ACCOUNT_JSON is not valid JSONPrivate key has literal newlinesRe-run the python3 single-line converter command from Step 3

Frequently asked questions

What OAuth scopes are required for the domain-wide delegation?

Three read-only Admin SDK scopes: https://www.googleapis.com/auth/admin.directory.user.readonly, https://www.googleapis.com/auth/admin.directory.group.readonly, and https://www.googleapis.com/auth/admin.directory.group.member.readonly. These allow Gateco to list users and groups without modifying your directory.

Does the service account need domain-wide delegation enabled in GCP Console as well as authorized in Google Admin console?

Yes, both steps are required. Enabling DWD in GCP Console makes the service account eligible for delegation, but the actual authorization (which account it can impersonate and with which scopes) happens separately in the Google Admin console under Security → API controls → Domain-wide delegation.

I set up everything correctly but 0 users are returned. What is wrong?

The most common cause is a domain mismatch. Verify that GCP_DOMAIN matches the primary domain in your Google Workspace account — go to Admin console → Account → Account settings → Profile to check. Do not use an alias domain or subdomain. Also verify that GCP_ADMIN_EMAIL belongs to a super-admin in that domain.

Ready to add policy-aware retrieval?

Connect your GCP setup to Gateco in under 5 minutes.