ahlan hamad

Setup guide · Google Workspace · Coming soon

Set up Google Workspace accounts for joiners and leavers: step by step

This guide is for two people working together: your Google Workspace super admin, who creates the service account and authorises it in Google Admin, and a company admin in AhlanHamad, who connects it. Follow it in order. Every AhlanHamad label below is the one you will see on screen.

Updated 12 October 2026

1. Before you start

Coming soon. You can create the service account and connect Google Workspace today, and AhlanHamad checks the connection with Google. Suspending leavers, reactivating rehires and creating accounts for new hires stay switched off until we switch them on for your company; until then the Google Workspace page shows only the connection.

CheckWhat you need
Where it standsBuilt, and tested only against a simulated Google Admin API. It hasn't run in a real Workspace yet, so when we switch it on for you, watch the first changes on the Activity tab.
Google WorkspaceYour organisation's Google Workspace, and a super admin: only a super admin can authorise domain-wide delegation in Google Admin (Google Admin Help).
A Google Cloud projectAny project your organisation owns, to hold the service account. A new one, for example ahlanhamad-hr, keeps it apart from everything else (Google: create a project).
In AhlanHamadA company admin who can manage settings, to connect Google Workspace and choose the account settings.

Never deleted. AhlanHamad never deletes a Google account and has no setting that would. A leaver's account is suspended; deleting it, and deciding what happens to its mail and files, stays with you in Google Admin.

2. In Google Cloud: create the service account and its key

Sign in to the Google Cloud console with an account of your organisation, and pick (or create) the project from section 1.

  1. Turn on the Admin SDK API (Google's developer pages also call it the Directory API): APIs & Services → Library, search for “Admin SDK”, open it and click Enable. Or open Google's direct link with the project selected (Google: enable APIs).
  2. Create the service account: Menu → IAM & Admin → Service Accounts → Create service account. Name it, for example ahlanhamad-directory, and click Create and continue. It needs no Google Cloud role: skip the optional role and user-access steps and click Done (Google: create access credentials).
  3. Click the new service account's email, open the Keys tab → Add key → Create new key → JSON → Create. A .json file downloads. Keep it safe: Google says it is the only copy of the key, and you paste its whole content into AhlanHamad in section 4 (Google: create and delete keys).
  4. Note the service account's Client ID, a long number: on the service account, click Show advanced settings and copy it under Domain-wide delegation. It is also the client_id inside the JSON file. You need it in section 3.

Can't create a key? Google Cloud organisations created on or after 3 May 2024 block service-account keys by default (the organisation policy iam.disableServiceAccountKeyCreation). An Organization Policy Administrator can exempt this one project (Google: create and delete keys, secure-by-default organisations). AhlanHamad connects with a JSON key; it has no keyless option today.

3. In Google Admin: authorise domain-wide delegation

Domain-wide delegation lets the service account act as one of your admins, limited to the scopes you list. A super admin does this once (Google Admin Help).

  1. Sign in to the Google Admin console as a super admin.
  2. Go to Menu → Security → Access and data control → API controls.
  3. Click Manage Domain Wide Delegation, then Add new.
  4. Client ID: the service account's Client ID from section 2.
  5. OAuth scopes: paste exactly https://www.googleapis.com/auth/admin.directory.user,https://www.googleapis.com/auth/admin.directory.orgunit.readonly (the two scopes, separated by a comma). If your screen asks for one scope per box, add the two separately.
  6. Click Authorize. To check, point at the entry and click View details: both scopes must be listed. Google says changes can take up to 24 hours but usually work sooner; if Connect fails straight after, wait and try again.
ScopeWhy AhlanHamad asks for it
https://www.googleapis.com/auth/admin.directory.userRequired. Reading your users (to link them to employees), suspending and reactivating linked accounts, and creating accounts for new hires if you switch that on (Directory API scopes).
https://www.googleapis.com/auth/admin.directory.orgunit.readonlyRead-only, for one thing: listing your organisational units so you can choose where new accounts go. Without it, everything else works and the picker says to add it.

AhlanHamad asks for nothing else: no groups, no Gmail, no Drive. Once account changes are switched on, the Connection tab shows Domain-wide delegation with the client ID and these exact scopes, so you can compare them with Google Admin.

4. In AhlanHamad: connect Google Workspace

  1. Go to Integrations and open Google Workspace. The card is called Google Workspace Connection.
  2. Primary Domain: your organisation's primary domain, for example company.com.
  3. Admin Email: the email of a super admin. The service account acts as this person (“A super-admin email to impersonate via domain-wide delegation.”). If that admin leaves or loses the role, Google stops accepting the connection, so pick an account your IT team keeps.
  4. Service Account JSON: open the .json file from section 2 in a text editor and paste all of it. It is “Stored encrypted on the server — never shown again and never sent to the browser.”
  5. Click Connect Google Workspace. While it checks, the button says Verifying Connection. AhlanHamad asks Google for a real access token with your delegation; the card then says Connected to Google Workspace with your Primary Domain.
  6. After connecting you can delete the downloaded .json file from your computer. If you ever need to connect again, create a new key.

Until account changes are switched on for your company, the page stays at this connection card: nothing is suspended or created.

5. Account changes (once switched on for your company)

When we switch account changes on, the Google Workspace page gets four tabs: Connection, Account lifecycle, Import and Activity. Its description becomes “Suspends a departed employee's Google account at the end of their last day, reactivates it on rehire, and can create accounts for new hires. Accounts are never deleted.”

First: link the accounts your staff already have

  1. On the Connection tab, check the Domain-wide delegation card against Google Admin and press Test connection. “Google accepted the connection. Waiting changes are running again.” means it works.
  2. Open Import and click Read Google directory. Each Google user is matched to an employee: exact email first, then similar names.
  3. Tick the matches that are right and click Link selected. Nothing is linked until you confirm, and nothing changes in Google. Users with no match (shared mailboxes, service accounts, ex-staff) are left alone.

Then: choose what happens

  1. Open Account lifecycle. Suspend the Google account when an employee leaves decides whether leavers are suspended.
  2. Create Google accounts for new hires is off until you turn it on. If you do, choose the Address pattern (first.last, flast, first or Custom), the organisational units (click Load from Google; this needs the second scope from section 3), and who receives the temporary password under Send the temporary password to (HR or The employee's manager).
  3. Click Save.

6. Troubleshooting

What you seeWhat to do
Please enter your API key or credentialsFill in all three fields: Primary Domain, Admin Email and Service Account JSON.
Service account JSON is not valid JSON.Paste the whole file again, from the first { to the last }, without adding anything.
Service account JSON must include client_email and private_key.That is not a service-account key file. Create a JSON key on the service account's Keys tab (section 2) and paste it.
Failed to authenticate with Google. Check the service account, domain-wide delegation, and admin email.Google refused the token. Check, in this order: the Client ID in Google Admin is this service account's; the scopes are exactly the ones in section 3; the Admin Email is an active super admin of this domain; the key wasn't deleted. A new delegation entry can take up to 24 hours; try again later.
Google account changes are pausedGoogle refused the service account after it worked (delegation removed or narrowed, the admin email suspended or no longer an admin, the key deleted). Fix it in Google Admin or Google Cloud (reconnect with a new key if you deleted it), then press Test connection. Nothing waiting is lost.
Google refused the request (HTTP 403). Check domain-wide delegation for the scopes shown on this page.The token was issued but Google refused the call: usually the user scope is missing from the delegation entry, or the admin email has no right to manage users. Correct it and press Test connection again.
Google refused the org-unit list. Add the org-unit scope shown on the Connection tab to domain-wide delegation.Edit the delegation entry in Google Admin and add the second scope from section 3. Nothing else is affected.
… already exists in Google. Link it to this employee if it is theirs.A new hire's address is taken by an existing user. If it is theirs, click Link existing on the Activity row; if not, choose another pattern and press Retry.

7. Disconnecting

  1. In AhlanHamad, go to Integrations → Google Workspace and click Disconnect Google Workspace. AhlanHamad deletes the stored key and makes no more changes in Google.
  2. AhlanHamad cannot withdraw anything at Google for you. To close the door completely, delete the key on the service account's Keys tab in Google Cloud, and remove the client ID under Manage Domain Wide Delegation in Google Admin.

Google sources used in this guide

About AhlanHamad × Google Workspace· All integrations