---
title: "Google Workspace"
description: "Export users, groups, and group memberships from Google Workspace and fulfill users, passwords, and memberships with the Identity Manager connector."
sidebar_position: 70
---

# Google Workspace

This connector exports and fulfills users and groups from/to a [Google Workspace](https://developers.google.com/workspace) instance.

This page is about [Google Workspace](../references-packages/googleworkspace.md).

![Package: Directory/Google Workspace](/images/identitymanager/packages_workspace_v603.webp)

## Overview

Google Workspace provides a set of software products developed by Google. The Google Workspace connector exports users, groups, and user-group memberships from a Google Workspace instance, and provisions users, their passwords and their group memberships to it.

| Scope | Export | Fulfill |
| --- | --- | --- |
| Users | ✅ | ✅ create, update, delete |
| Groups | ✅ | ❌ |
| Group memberships | ✅ | ✅ add, remove |
| Passwords | N/A | ✅ at creation and by reset |

:::note
Organizational units, roles, and role assignments are neither exported nor fulfilled.
:::

## Prerequisites

Implementing this connector requires:

- reading first the
[appsettings.agent](../../network-configuration/agent-configuration/appsettings-agent.md)documentation;
- a service account impersonating the following permission scopes:

| Scope | Usage |
| --- | --- |
| [https://www.googleapis.com/auth/admin.directory.user](https://www.googleapis.com/auth/admin.directory.user) | Export and fulfill of users |
| [https://www.googleapis.com/auth/admin.directory.group](https://www.googleapis.com/auth/admin.directory.group) | Export of groups and memberships, fulfill of memberships |
| [https://www.googleapis.com/auth/admin.directory.userschema.readonly](https://www.googleapis.com/auth/admin.directory.userschema.readonly) | Discovery of custom user schemas (optional) |

See [Google's documentation](https://developers.google.com/workspace/guides/create-credentials#service-account-credentials) to create the service account with the right impersonation.

:::tip
 Remember, Google's documentation describes this procedure as optional, while the Google Workspace connector requires it. 
:::

:::note
 Without the `admin.directory.userschema.readonly` scope, the schema refresh still returns all standard attributes but doesn't include custom schema columns.
:::

To fulfill users with passwords, the agent configuration must also contain the `MailSettings` and `PasswordResetSettings` sections (including the encryption certificate), as for the other connectors that support password reset.

## Export

This connector extracts users, groups, and user-group memberships from a Google Workspace instance, and writes the output to CSV files.

### Configuration

This process is configured through a [Connection](../../../integrations/toolkit/xml-configuration/connectors/connection.md) in the UI and/or the XML configuration, and in the `*appsettings.agent.json* > Connections` section:

```json
*appsettings.agent.json*
{
  ...
  "Connections": {
    ...
    "<ConnectionIdentifier>": {
      ...
    }
  }
}
```

The identifier of the connection and thus the name of the subsection must:

- be unique.
- not begin with a digit.
- not contain `<`, `>`, `:`, `"`, `/`, `\`, `|`, `?`, `*` and `_`.

> For example:
>
> ```
>
> *appsettings.agent.json*
> {
>     ...
>     "Connections": {
>         ...
>         "GoogleExportFulfillment": {
>             "CredentialsFilePath": "C:/identitymanagerDemo/GoogleCredentials.json",
>             "User": "B29607@acme.internal",
>             "PageSize": "100"
>         }
>     }
> }
>
> ```

#### Setting attributes

 | Name | Details | 
 | --- | --- | 
 | CredentialsFilePath required | **Type** String **Description** Path of Google Workspace's JSON credentials file. [See Google's documentation to **create** these credentials](https://developers.google.com/workspace/guides/create-credentials#service-account-credentials). | 
 | User required | **Type** String **Description** Email address of the service account mentioned in the prerequisites section. | 
 | PageSize default value: 50 | **Type** Int32 **Description** Number of items, i.e. users and/or groups and/or memberships, retrievable from Google Workspace by each API call (from 1 to 500). | 

### Output details

This connector is meant to generate to the [Application Settings](../../network-configuration/agent-configuration/appsettings.md)Export Output folder the following CSV files:

- `GoogleExportFulfillment_Users.csv` and `GoogleExportFulfillment_Groups.csv` whose headers come
from the entity type mapping's `ConnectionColumn` and from the entity association mappings' columns which aren't _members_ columns;
- `GoogleExportFulfillment_Members.csv` with the following columns:
    - **value**: ID of the group;
    - **MemberId**: ID of the group member.

| Column type | Column name | Example |
| --- | --- | --- |
| Single property | `{property}` | `PrimaryEmail`, `Suspended` |
| Sub-property | `{property}:{sub-property}` | `Name:FamilyName` |
| Custom schema | `CustomSchemas:{schema}:{field}` | `CustomSchemas:NimData:VIP` |
| Structured list | `{list}:{property}` | `Phones:Value`, `Phones:Type` |
| Text list | `{property}` | `Aliases`, `NonEditableAliases` |

The character `":"` shouldn't be used in other situations.

> For example:
>
> ```
>
> <EntityType Identifier="GOOGLE_Entry" DisplayName_L1="GOOGLE - Entry" DisplayName_L2="GOOGLE - Entree">  <Property Identifier="AgreedToTerms" DisplayName_L1="AgreedToTerms" Type="String" />  <Property Identifier="FamilyName" DisplayName_L1="FamilyName" Type="String" /></EntityType><EntityTypeMapping Identifier="GOOGLE_Entry" Connector="GOOGLE" ConnectionTable="GOOGLE_Users">  <Property Identifier="AgreedToTerms" ConnectionColumn="AgreedToTerms" />  <Property Identifier="FamilyName" ConnectionColumn="Name:FamilyName" /></EntityTypeMapping>
>
> ```
>
> This example has `AgreedToTerms`, which is a single property, and `FamilyName` which is a
> sub-property of `Name`, hence the name `Name:FamilyName` as the `ConnectionColumn`.

#### Structured lists

The structured lists of a user are `Emails`, `ExternalIds`, `Organizations`, `Phones`, `Addresses`, `Ims`, `Relations` and `Websites`. Each element property gives one multi-valued text column, for example `Phones:Value` and `Phones:Type`. Nested objects are flattened in the name, for example `Emails:PublicKeyEncryptionCertificates:Certificate`. Groups export `ExternalIds:*` the same way.

The columns of a list are aligned by position: the nth value of each column describes the nth element. The primary element comes first. A missing value leaves an empty line, and the empty lines at the end of a column are left out.

> For example, a user has two phones and only the second one has a type:
>
> | Position | `Phones:Value` | `Phones:Type` |
> | --- | --- | --- |
> | 1 | `+33 1 23 45 67 89` | _(empty)_ |
> | 2 | `+33 6 12 34 56 78` | `Work` |
>
> The exported values are `Phones:Value` = `+33 1 23 45 67 89\n+33 6 12 34 56 78` and `Phones:Type` = `\nWork`, where `\n` is the line break separating the values.

#### Custom schemas

Custom schema fields are exported with the columns `CustomSchemas:{schema}:{field}`. Multi-valued fields are exported as multi-valued texts. They require the `admin.directory.userschema.readonly` scope to be discovered by the schema refresh.

#### Aliases

`Aliases` and `NonEditableAliases` are lists of texts, without element properties. Each one gives a single multi-valued column, with one address per line, sorted alphabetically. `Aliases` is exported for users and groups, `NonEditableAliases` for users only. A resource without alias gives an empty value.

```xml
<Property Identifier="Aliases" ConnectionColumn="Aliases" />
<Property Identifier="NonEditableAliases" ConnectionColumn="NonEditableAliases" />
```

`NonEditableAliases` contains the addresses derived from the secondary domains, which Google manages itself.

The order of the values matters when comparing exported and provisioned values: see [Focus on MultivaluedText](../entitypropertymapping-format.md#focus-on-multivaluedtext).

## Fulfill

This connector can write to Google Workspace to **create**, **update**, and/or **delete** users, and to **add** and **remove** user-group memberships.

### Configuration

Same as for export, fulfill is configured through connections.

> For example:
>
> ```
>
> *appsettings.agent.json*
> {
>     ...
>     "Connections": {
>         ...
>         "GoogleExportFulfillment": {
>             "CredentialsFilePath": "C:/identitymanagerDemo/GoogleCredentials.json",
>             "User": "B29607@acme.internal"
>         }
>     }
> }
>
> ```

#### Setting attributes

 | Name | Details | 
 | --- | --- | 
 | CredentialsFilePath required | **Type** String **Description** Path of Google Workspace's JSON credentials file. [See Google's documentation to **create** these credentials](https://developers.google.com/workspace/guides/create-credentials#service-account-credentials). | 
 | User required | **Type** String **Description** Email address of the service account mentioned in the prerequisites section. | 

### Setting up the provisioning

#### 1. Resource type mapping

The `GoogleWorkspaceResourceTypeMapping` declares the connection, the password reset setting and the key property. The key property holds the Google identifier of the user and is required to update or delete an account.

```xml
<GoogleWorkspaceResourceTypeMapping Identifier="User_To_GOOGLE_Entry" Connection="GOOGLE"
                                    PasswordResetSetting="GoogleWorkSpacePasswordSetting">
  <KeyProperty Property="GoogleId" />
  <MultiValuedProperty Property="CustomSchemas_NimData_MultiValueTest" />
</GoogleWorkspaceResourceTypeMapping>
```

- `KeyProperty`: property mapped to the Google `Id` column.
- `MultiValuedProperty`: custom schema fields that hold several values. The values are separated by line breaks. An empty value clears the field.

See [GoogleWorkspaceResourceTypeMapping](../../../integrations/toolkit/xml-configuration/connectors/resourcetypemappings/googleworkspaceresourcetypemapping.mdx). The same settings are available in the resource type mapping form of the UI.

#### 2. Single properties and custom schemas

The values of properties declared with a type (`Bool`, `Int64`, `DateTime`) are converted to this type before being sent to Google.

#### 3. Structured lists

Structured lists are provisioned with one rule per `{list}:{property}` column. Each rule returns a multi-valued text, one element per line.

```xml
<ScalarRule Property="Phones_Value" Policy="Default"
            Expression="C#:record: return string.Join(&quot;\n&quot;, new[] { record.MobileNumber, record.PhoneNumber }.Where(s => !string.IsNullOrEmpty(s)));" />
<ScalarRule Property="Phones_Type" Policy="Default" Expression="Literal:mobile&#10;work" />
```

- The nth value of each column builds the nth element.
- The order of the values must match the exported one, otherwise the provisioning is never verified: see [Focus on MultivaluedText](../entitypropertymapping-format.md#focus-on-multivaluedtext).
- An empty value leaves the property unset. An element without any value is left out.
- Only the properties exported by the connector are accepted. A value that doesn't match the property type raises an error naming the column and the value. Google validates the rest (types, `customType`).
- Nested paths such as `Emails:PublicKeyEncryptionCertificates:*` aren't supported.

Google replaces a list as a whole. To clear:

| Goal | Rule |
| --- | --- |
| A whole list | Return empty values for all its columns: the connector sends `[]` |
| One element | Return the list without this element |
| One property of an element | Leave an empty line at its position |

A position missing at the end of a column is treated as unset, so a rule can leave a column shorter than the others.

:::warning
When a list is modified, the connector completes it with the current values of the resource. Values added manually in the Admin console that aren't in the rule are overwritten.
:::

Google accepts only one relation of type `manager`: the rules must send the manager of the main record only, otherwise Google rejects the order (HTTP 412).

## Emails

- The export of the `Emails:*` columns excludes the primary address (`PrimaryEmail`), the aliases (`Aliases`) and the non-editable aliases (`NonEditableAliases`), which Google manages itself. The comparison ignores the case.
- `Aliases` and `NonEditableAliases` are exported in their own column, as sorted multi-valued texts.
- Fulfill replaces the whole list of secondary addresses: addresses added manually in the Admin console are overwritten.
- An empty list clears the secondary addresses without touching the primary address or the aliases.
- `Emails:Primary` has no effect on write: Google ignores the primary flag of a secondary address.
- A secondary address without a type shifts the `Emails:Type` and `Emails:Address` columns: always set a type in the rule.
- The `Emails:PublicKeyEncryptionCertificates:*` columns are read-only.

## Authentication

### Password reset

The connector sets the password of a new account at creation, and resets the password of an existing account on request.

#### Setting

The [password reset setting](../../../integrations/toolkit/xml-configuration/connectors/passwordresetsettings.md) is referenced by `PasswordResetSetting` in the resource type mapping.

#### Behavior

| Mode | At account creation | Reset |
| --- | --- | --- |
| Direct | The generated password is set at creation, to be changed at the first login, and sent by mail | Direct or indirect reset from the UI |
| Two-factor | A random throwaway password is set, and the user chooses a password through a link received by mail | Direct or indirect reset from the UI |

- Google requires a password to create an account. The throwaway password is always random: it ignores the configured default password.
- Google validates the password. At creation, a rejection fails the provisioning order. At reset, the error is shown in the UI. Use `StrengthCheck` (for example `^.{8,100}$`) to filter passwords beforehand.
- Changing the password and unlocking the account aren't available: the Directory API can't verify the old password and has no lock.

### Credential protection

This connector has no credential attributes, and therefore doesn't use [RSA Encryption](../../network-configuration/agent-configuration/rsa-encryption.md), nor a [CyberArk's AAM Credential Providers ](../../network-configuration/agent-configuration/cyberark-application-access-manager-credential-providers.md)Vault.

Still, data protection can be ensured through an [Azure Key Vault](../../network-configuration/agent-configuration/azure-key-vault.md) safe.

## Limitations

- Groups aren't fulfilled, only their memberships.
- Organizational units, roles, and role assignments are neither exported nor fulfilled.
- Nested paths in structured lists aren't supported on write.
- Only one `manager` relation per user.
