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.
| Check | What you need |
|---|---|
| Where it stands | Built, 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 Workspace | Your organisation's Google Workspace, and a super admin: only a super admin can authorise domain-wide delegation in Google Admin (Google Admin Help). |
| Google Cloud | Nothing, 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 AhlanHamad | A 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.
- In AhlanHamad, open Integrations → Google Workspace. The Connection tab shows AhlanHamad's client ID and the OAuth scopes, each with a Copy button.
- 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).
- 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. - 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.
| Scope | Why AhlanHamad asks for it |
|---|---|
https://www.googleapis.com/auth/admin.directory.user | Required. 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.readonly | Read-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
- 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.
- Open Import and click Read Google directory. Each Google user is matched to an employee: exact email first, then similar names.
- 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
- Open Account lifecycle. Suspend the Google account when an employee leaves decides whether leavers are suspended.
- Create Google accounts for new hires is off until you turn it on. If you do, choose the Address pattern (
first.last,flast,firstor 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). - Click Save.
- When someone leaves: their linked Google account is suspended at the end of their last working day, in your company's time zone. A rehire reactivates it, and a suspension still waiting is cancelled (what suspension does in Google).
- New hires (only if switched on): an address from your pattern, with a number added when one is taken (
sara.ali2). The temporary password is emailed once; AhlanHamad keeps no copy, and the person changes it at first sign-in. - Activity lists each change: Create account, Suspend, Reactivate, with its status. Needs you means a person must act (the reason is shown); Retry queues it again.
- AhlanHamad doesn't touch Google users who aren't linked to an employee, doesn't manage groups, aliases or licences, and doesn't change a profile (title, department) after the account is created.
4. Troubleshooting
| What you see | What to do |
|---|---|
| Please enter your API key or credentials | Fill 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 paused | Google 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
- 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.
- 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.
- Accounts already suspended stay suspended; AhlanHamad never deletes or changes them after you disconnect.
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.
- 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).
- 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). - Click the new service account's email, open the Keys tab → Add key → Create new key → JSON → Create. A
.jsonfile 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). - 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_idinside 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).
- Sign in to the Google Admin console as a super admin.
- Go to Menu → Security → Access and data control → API controls.
- Click Manage Domain Wide Delegation, then Add new.
- Client ID: the service account's Client ID from section 6.1.
- 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. - 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
- 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).
- Primary Domain: your organisation's primary domain, for example
company.com. - 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.
- Service Account JSON: open the
.jsonfile 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.” - 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.
- After connecting you can delete the downloaded
.jsonfile 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
- Google Workspace Admin Help: control API access with domain-wide delegation, suspend a user.
- Google Workspace developers: create access credentials (service account and key), domain-wide delegation for a service account, Directory API scopes.
- Google Cloud: create a project, enable an API, create and delete service account keys, secure-by-default organisations (key creation policy).
- Google's menus change from time to time. If a name here doesn't match your screen, the linked page has Google's current wording.