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 authorises AhlanHamad's client ID in Google Admin, and a company admin in AhlanHamad, who connects it. Most companies need only section 2: no Google Cloud project and no key. Every AhlanHamad label below is the one you will see on screen.

Updated 12 October 2026

1. Before you start

Coming soon. You can 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).
Google CloudNothing, with the keyless setup in section 2. Only the advanced setup with your own service account key (section 6) needs a Google Cloud project of your organisation (Google: create a project).
In AhlanHamadA company admin who can manage settings, to connect Google Workspace and choose the account settings. For the keyless setup, the person who connects must also be an admin in your Google Workspace.

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. Connect without a key (recommended)

You don't create a Google Cloud project, a service account or a key. You authorise AhlanHamad's client ID in your own Google Admin console, and you can remove it there at any time. Newer Google Cloud organisations block service-account keys by default (Google: secure-by-default organisations), so this is the setup that works without changing any security policy.

  1. In AhlanHamad, open Integrations → Google Workspace. The Connection tab shows AhlanHamad's client ID and the OAuth scopes, each with a Copy button.
  2. A super admin signs in to the Google Admin console and opens Menu → Security → Access and data control → API controls → Manage Domain Wide Delegation, then clicks Add new (Google Admin Help).
  3. Paste the client ID, and paste the scopes exactly as shown: https://www.googleapis.com/auth/admin.directory.user,https://www.googleapis.com/auth/admin.directory.orgunit.readonly. Click Authorize. Google can take a few minutes, occasionally up to 24 hours, to apply it.
  4. Back in AhlanHamad, enter your Primary Domain and, under Admin Email, the email of a super admin, then click Connect and test. AhlanHamad reads one user from your directory to check that it works, and says Connected to Google Workspace only if Google answers.
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.

Sign in as a Workspace admin to connect. Because one AhlanHamad client ID serves every customer, the person who clicks Connect and test must be signed in to AhlanHamad with their own admin account in the same Google Workspace. That stops another company from connecting your Workspace. If your HR lead isn't a Google admin, invite your IT admin to AhlanHamad to connect, or use your own service account key (section 6).

Removing access. Disconnecting in AhlanHamad forgets your settings there. To remove AhlanHamad's access at Google, delete the entry with AhlanHamad's client ID from Manage Domain Wide Delegation. It takes effect at Google, without AhlanHamad.

3. 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 2), and who receives the temporary password under Send the temporary password to (HR or The employee's manager).
  3. Click Save.

4. Troubleshooting

What you seeWhat to do
Please enter your API key or credentialsFill in Primary Domain and Admin Email, and with your own key (section 6) also Service Account JSON.
Google hasn't authorised Ahlan Hamad yet.Keyless: the client ID isn't in Manage Domain Wide Delegation yet, or its scopes differ. Add it with exactly the scopes in section 2. If you just added it, wait a few minutes and click Connect and test again.
To connect without a key, sign in to Ahlan Hamad with your own admin account in this Google Workspace.The person connecting isn't an admin in this Google Workspace. Ask your Google admin to sign in to AhlanHamad and connect, or use your own key (section 6).
Google doesn't recognise the admin email.Enter the email of an active super admin in this Google Workspace under Admin Email.
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 6.1) 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 2; 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 2. 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.

5. Disconnecting

  1. In AhlanHamad, go to Integrations → Google Workspace and click Disconnect Google Workspace. AhlanHamad forgets your settings (with your own key, it deletes the stored key) and makes no more changes in Google.
  2. AhlanHamad cannot withdraw anything at Google for you. Keyless: delete the entry with AhlanHamad's client ID under Manage Domain Wide Delegation in Google Admin; the page reminds you (One more step in Google Admin) and shows the client ID. Own key: remove its client ID there too, and delete the key on the service account's Keys tab in Google Cloud.

6. Advanced: your own service account key

Use this only if you can't use the keyless setup in section 2, or your IT policy asks for a service account your organisation owns. You create the service account and its key in your own Google Cloud project (6.1), authorise its client ID in Google Admin (6.2) and paste the key into AhlanHamad (6.3). Sections 3 to 5 work the same either way.

You hold a key. A service account key is a long-lived secret: anyone with the file can act as the service account. AhlanHamad stores it encrypted and never shows it again, and you can delete the downloaded file after connecting. Keyless setup avoids the key entirely.

6.1 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) a project to hold the service account. A new one, for example ahlanhamad-hr, keeps it apart from everything else.

  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 6.3 (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 6.2.

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). Or skip the key altogether: the keyless setup in section 2 needs no service account key.

6.2 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 6.1.
  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.

These are the same two scopes as in section 2, where the table says why AhlanHamad asks for each.

6.3 In AhlanHamad: connect with your own key

  1. Go to Integrations and open Google Workspace. The card is called Google Workspace Connection. If it shows the keyless steps, click Use your own service account key (advanced).
  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 6.1 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.

Google sources used in this guide

About AhlanHamad × Google Workspace· All integrations