# G-Suite

Collaboration & Productivity Apps for Business

## Overview

The Tray.io G Suite connector allows you to manage your organisation in G Suite.

## Authentication

**Note:** Before authenticating this Google connector, you will need to whitelist the Tray.io Google authentication app. Please follow the instructions [here](https://tray.ai/documentation/platform/connectivity/authenticating-google-connectors) before continuing with the authentication process.
Once this is done, you can click on the **New Authentication** button:
![g-suite-auth](https://tray.ai/documentation/images/connectors/service/g-suite/990c0297-8eb8b8c8_g-suite-auth.png)
Check every scope to allow Tray the correct permissions, then proceed to log in to your G Suite account.

## Available Operations

The examples below show one or two of the available connector operations in use.
Please see the [Full Operations Reference](#operationsFull) at the end of this page for details on all available operations for this connector.

## Example

In the following example we create a workflow that retrieves a list of users and assigns one of the users to a group.
To begin with, create a workflow with a **Manual Trigger**, then add a step from the **G Suite** connector with the operation set to `List Users`. Set the 'Customer' parameter to **"my\_customer"**, this is a keyword that specifies your own account. This will output a list of users:
![g-suite-list-users](https://tray.ai/documentation/images/connectors/service/g-suite/990c0297-fd7853d9_g-suite-list-users.png)
Next, we add a step from the G Suite connector with the operation set to `Get user`, to retrieve one of the users from the list. Set the `User key` to the ID of one of the users, by using a JsonPath as shown in the example:
![g-suite-get-users](https://tray.ai/documentation/images/connectors/service/g-suite/990c0297-c76c6285_g-suite-get-users.png)
Then, we add a step with the operation set to `List groups`, enter the domain associated with our account, and in the output we retrieve a list of groups in our account:
![g-suite-list-groups](https://tray.ai/documentation/images/connectors/service/g-suite/990c0297-40889de2_g-suite-list-groups.png)
We use the output of this step to find the ID of a group. We add another step with the operation set to `Add member to group`, set the `Group key` to the `id` of one of the groups, and the `User key` to the `primaryEmail` of the user we returned in `Get user`:
![g-suite-add-member](https://tray.ai/documentation/images/connectors/service/g-suite/990c0297-701e7abf_g-suite-add-member.png)
Finally, we use the `Check group membership` operation to verify the membership, setting the `Group key` as above, and setting the `Member key` to the `primaryEmail` of the user, as in the `User key` above. The operation should return `isMember: true` in the output:
![g-suite-check-group-membership](https://tray.ai/documentation/images/connectors/service/g-suite/990c0297-23df2ecf_g-suite-check-group-membership.png)
