# Create Google Group

Creates Google Workspace groups with configurable settings and ownership

Creates a Google Workspace group with configurable settings and automatically assigns ownership to a specified user.

## Setup Requirements

Before using this tool, you must configure Google service account authentication with proper domain-wide delegation. This requires Google Workspace Super Admin access.

### Quick Reference

**Required APIs**:

- Admin SDK API
- Groups Settings API

**Required OAuth Scopes**:

```
https://www.googleapis.com/auth/admin.directory.group,https://www.googleapis.com/auth/apps.groups.settings
```

**Google Admin Console Path**:
Menu > Security > Access and data control > API controls > Manage Domain Wide Delegation

## Step-by-Step Setup

### Step 1: Enable Required APIs in Google Cloud Console

1. Go to the [Google Cloud Console](https://console.cloud.google.com/)
2. Select your project (or create a new one)
3. Navigate to **APIs & Services > Library**
4. Search for and enable the following APIs:
   - **Admin SDK API** - Click "Enable"
   - **Groups Settings API** - Click "Enable"

### Step 2: Create Service Account

1. In Google Cloud Console, go to **IAM & Admin > Service Accounts**
2. Click **+ CREATE SERVICE ACCOUNT**
3. Fill in the details:
   - **Service account name**: `google-groups-automation` (or your preferred name)
   - **Service account ID**: Will auto-populate
   - **Description**: `Service account for Google Groups creation tool`
4. Click **CREATE AND CONTINUE**
5. Skip the optional steps and click **DONE**

### Step 3: Enable Domain-Wide Delegation

1. In the Service Accounts list, click on your newly created service account
2. Go to the **Details** tab
3. In the **Advanced settings** section, check **Enable Google Workspace Domain-wide Delegation**
4. Enter a **Product name for the consent screen**: `Google Groups Tool`
5. Click **SAVE**
6. **Important**: Copy the **Client ID** from the service account details - you'll need this for Step 5

### Step 4: Create and Download Service Account Key

1. Still in your service account details, click the **KEYS** tab
2. Click **ADD KEY > Create new key**
3. Select **JSON** format
4. Click **CREATE**
5. The JSON file will download automatically - **save this securely**

> **Note:** If key creation is disabled in your organization, you may need to ask your IT
> admin to temporarily enable it, or create the service account in a different
> Google Cloud project.

### Step 5: Configure Domain-Wide Delegation in Google Workspace

**Warning:** This step requires Google Workspace Super Admin privileges.

1. Go to [Google Admin Console](https://admin.google.com/)
2. In the menu, navigate to **Security > Access and data control > API controls**
3. Click **Manage Domain Wide Delegation**
4. Click **Add new**
5. Enter the following details:
   - **Client ID**: Paste the Client ID from Step 3
   - **OAuth scopes**:
     ```
     https://www.googleapis.com/auth/admin.directory.group,https://www.googleapis.com/auth/apps.groups.settings
     ```
6. Click **Authorize**

### Step 6: Configure the Tool in Risotto

1. In the Risotto dashboard, select **Tools** in the sidebar.
2. In the **Tool groups** list, select **Google**.
3. Find **Create Google Group** and click **Set up**.
4. Fill in the tool configuration:
   - **Service Account JSON file**: The downloaded JSON key file
   - **Domain**: Your Google Workspace domain (e.g., "company.com")
   - **Admin User Email**: Email of a user with Super Admin or Groups Admin privileges
   - **Default Group Settings**: Optional default settings for created groups

## Configuration Options

When configuring this tool in a runbook, you can set:

- **Group Name** - Display name for the group
- **Group Email** - Email address for the group (e.g., <team@company.com>)
- **Owner Email** - Email of the user who will own the group
- **Description** - Description of the group's purpose

## Limitations

- The tool acts as the admin user that you set in **Admin User Email**.
- The tool checks only that the group email ends with your configured domain. It does not check whether the address matches a user's email address or alias.
- The tool does not check that the owner email belongs to a user. If Google refuses to add the owner, the tool creates the group and shows the warning "Could not add \<owner email> as owner".

To enforce a naming rule or require approval, attach an [approval policy](https://www.tryrisotto.com/docs/dashboard/settings/approval-policies#attaching-a-policy-to-a-tool) to the tool, or use a [script tool](https://www.tryrisotto.com/docs/integrations/tools/script-tools) that checks the address first.

## Troubleshooting

### Common Issues

#### 403 Forbidden Error

**Cause**: Domain-wide delegation not configured properly

**Solution**:

- Verify the Client ID in Google Admin Console matches your service account
- Ensure OAuth scopes are exactly as specified
- Wait 15-30 minutes for changes to propagate

#### Not Authorized to access this resource/api

**Cause**: Missing subject impersonation or insufficient admin privileges

**Solution**:

- Ensure `admin_user_email` is a real user with admin privileges
- Verify the user account is active (not suspended)

#### Service account key creation is disabled

**Cause**: Organization policy restricts key creation

**Solution**:

- Ask your IT admin to temporarily enable key creation
- Or create the service account in a different Google Cloud project

### Permission Requirements

The admin user specified in `admin_user_email` must have one of these roles:

- **Super Admin** (recommended)
- **Groups Admin** (minimum required)

### Security Best Practices

1. **Rotate service account keys** regularly (every 90 days)
2. **Limit OAuth scopes** to only what's necessary
3. **Store JSON keys securely** - never commit to version control
4. **Monitor API usage** in Google Cloud Console
5. **Remove domain-wide delegation** when no longer needed

Source: https://www.tryrisotto.com/docs/integrations/tools/google/create_group
