Connect Google Workspace

What you need

  • A Google Workspace administrator account.
  • Your relay address: Administration > Integrations, card SMTP BCC relay, Set up, Your relay address. It looks like [email protected]. Always copy the full address.

Two parts:

  • Routing rule: archives every new message. Required.
  • Connector: syncs users, groups and domains and imports existing Gmail mail. Optional. It does not replace the routing rule.

Create the routing rule

  1. In EasyMailArchive, open Administration > Integrations.
  2. On the SMTP BCC relay card, click Set up.
  3. Under Your relay address, click Copy.
  4. Open Gmail routing in the Google Admin console (Apps > Google Workspace > Gmail > Routing).
  5. At Routing, click Add another rule (or Configure if there is no rule yet).
  6. Under Messages to affect, tick Inbound, Outbound and Internal - sending and Internal - receiving.
  7. Under For the above types of messages, do the following, choose Modify message.
  8. Under Also deliver to, tick Add more recipients, click Add and paste the relay address.
  9. Click Save.
  10. Back in EasyMailArchive, click Done. You see "SMTP BCC source created."

Changes in Google take up to an hour.

Test the rule

  1. Wait until the rule is active.
  2. Send a mail from a Workspace mailbox to an outside address.
  3. Send a mail from outside to a Workspace mailbox.
  4. Send a mail between two Workspace mailboxes.
  5. Enter each subject in the search bar of your archive.
  6. Under Administration > Dashboard, the Compliance status card shows "Active, 3 emails archived".

Optional: Google Workspace connector

1. Prepare Google Cloud

  1. Create a Google Cloud project, or pick an existing one.
  2. In that project, enable the Admin SDK API: click Enable.
  3. In the same project, enable the Gmail API: click Enable.
  4. Open Service accounts and click Create service account. Give it a name. It needs no roles.
  5. Open the service account, tab Keys, Add key > Create new key, type JSON, Create. The JSON file downloads.
  6. Note the Unique ID (OAuth 2 client ID). It is the numeric client_id in the JSON file, not the email address.

Check the project selector at the top: both APIs must be enabled in the project that owns the service account.

2. Allow domain-wide delegation

  1. Open Domain-wide delegation in the Google Admin console (Security > Access and data control > API controls > Domain-wide delegation).
  2. Click Add new.
  3. Under Client ID, enter the numeric client ID.
  4. Under OAuth scopes, paste this line as it is:
https://www.googleapis.com/auth/gmail.readonly,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
  1. Click Authorize.
ScopeUsed for
gmail.readonlyImport of existing mail, read-only
admin.directory.user.readonlyUser sync, read-only
admin.directory.group.readonlyGroup sync, read-only
admin.directory.group.member.readonlyGroup member sync, read-only

3. Save the connector

  1. Open Administration > Integrations.
  2. On the Google Workspace card, click Set up. The Google Workspace setup dialog opens.
  3. Under Service account JSON key, click Choose JSON key file... and pick the downloaded file.
  4. Under Admin email, enter the address of a Workspace administrator.
  5. Under Domains, click Add domain and enter each Workspace domain.
  6. Optional: enter a Test mailbox (optional), e.g. your own address.
  7. Click Check. A checklist shows each step as Passed, Failed or Not checked:
    • Service account key valid
    • Admin SDK API enabled
    • Gmail API enabled
    • Domain-wide delegation with all four scopes
    • Admin email can act as admin
    • Test mailbox can list messages

    It also shows the project, Client ID and Scopes from your key. Fix any Failed step, then click Check again.
  8. Click Save. You see "Google Workspace connector created. Initial sync started."

What the connector does

  • Creates users, groups and domains from your Workspace directory.
  • Syncs once a day. Sync now on the card starts a sync at once.
  • Creates an import job per new user. Follow them under Administration > Import Jobs: Pending, Running, Finished, Failed.
  • View logs on the card lists every sync.

Troubleshooting

Errors appear in the checklist after Check and on the Google Workspace card.

ErrorFix
"Admin SDK API is not enabled", or from Google: "Admin SDK API has not been used in project … before or it is disabled"Enable the Admin SDK API in the project of the service account. The card offers Enable Admin SDK API. Wait 5 minutes, then click Check again.
"Gmail API is not enabled", or from Google: "Gmail API has not been used in project … before or it is disabled"Enable the Gmail API in the same project. The card offers Enable Gmail API. Wait 5 minutes, then Sync now.
"Domain-wide delegation not set up", or from Google: unauthorized_client "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."In Domain-wide delegation, check the client ID is the numeric ID of this service account and all four scopes are listed. Changes can take some minutes.
"Service account key invalid"The key was deleted or the file is damaged. Create a new JSON key on the service account's Keys tab. Delete the connector on the card (archived mail stays) and set it up again with the new file.
"Google Workspace connection failed"Check that Admin email is an active Workspace administrator, then test again.
"Service account JSON key is required."Choose the JSON file before saving.
"At least one domain is required."Click Add domain and enter your Workspace domain.
"The domain acme.com is already managed by another connector."Another connector already handles this domain. Remove it there first.
Routing rule: mail does not arriveAll four message types ticked? Relay address complete? Wait up to an hour. See Setting Up Email Journaling.