> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/action-center/google-workspace/assign-role-to-users.md).

# Assign Role to Users

Assigns one admin role to every user asset passed to this node. The assignment applies to the whole organization.

### Before you begin

* A Google service account with domain-wide delegation enabled. Paste the content of its JSON key file into **Service Account Key**.
* The email of a Workspace admin user for the job to impersonate (**Workspace Admin Email**).
* The service account must be authorized for the OAuth scope `https://www.googleapis.com/auth/admin.directory.rolemanagement` in the domain-wide delegation settings of your Google Workspace.
* Asset type: **User** (the only type this job accepts).
* Required column: `Specifics.google-directory.id` (the Google Directory ID). User assets without it are skipped.
* Defaults: you can save the connection fields once under **Action Center** > **Settings** > **Google Workspace** (each job has its own tab). See [Action Center Settings](broken://pages/463cb9354fc80aafe89eadc3c2511cf858c22856).

{% hint style="warning" %}
Admin roles grant powerful rights. Make sure the condition that feeds this job selects only the users who should receive the role.
{% endhint %}

### Settings

| Setting               | Type             | Required | Default | Description                                                                                                    |
| --------------------- | ---------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------- |
| Service Account Key   | Text (sensitive) | Yes      | None    | Content of the Google service account JSON key file, with domain-wide delegation enabled. Masked after saving. |
| Workspace Admin Email | Email            | Yes      | None    | Email of the admin user to impersonate through domain-wide delegation.                                         |
| Role ID               | Text             | Yes      | None    | ID of the admin role. You can list role IDs from the Google Admin console or the roles API.                    |
| Request Timeout       | Number           | No       | 30      | Timeout in seconds for API requests.                                                                           |

### How it works

* For each user asset the job sends one POST request to the role assignments endpoint with the **Role ID**, the user's Google Directory ID and `scopeType` set to `CUSTOMER` (the whole organization).
* Role assignment needs the immutable Google user ID, so the job accepts only assets that have `Specifics.google-directory.id`. The email is not used. Assets without that value are skipped without a message.
* If Google rejects a request (HTTP status 400 or higher) the job writes the status and response to the log and moves on to the next user. A rejected request does not fail the node. If the access token request fails (for example a wrong key or missing delegation), the job fails before it changes any user.
* The job passes on all assets it received, unchanged, through the **NEXT** edge.

This job is one of the Google Workspace jobs. To remove a role again, use [Unassign Role from Users](broken://pages/10feb50c49d6b1fa13ef39cc08bea45a27f072cc).

### Example

```
Condition: saved User query for the helpdesk team
Job: Google Workspace - Assign Role to Users
Role ID: YOUR_ROLE_ID
```

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>About Action Center</strong></td><td>Workflows, triggers, conditions and job nodes.</td><td><a href="broken://pages/b6784ce27913947f154229ea6e014c1e567d94fc">Broken link</a></td></tr><tr><td><strong>Action Center Settings</strong></td><td>Save connection defaults for Google Workspace jobs.</td><td><a href="broken://pages/463cb9354fc80aafe89eadc3c2511cf858c22856">Broken link</a></td></tr><tr><td><strong>Unassign Role from Users</strong></td><td>Remove the role from users.</td><td><a href="broken://pages/10feb50c49d6b1fa13ef39cc08bea45a27f072cc">Broken link</a></td></tr></tbody></table>
