GoogleApps API and G Suite
Use the GoogleApps API and G Suite integration to help administrators migrate to G Suite, create custom usage reports, and manage users, groups, and devices.
NOTE: The googleapps-gmail
commands are deprecated, to execute Gmail commands, use the Gmail integration.
#
PrerequisitesThere are several procedures you have to perform in Google before configuring the integration on Demisto.
- Get a New Private Key
- Delegate Domain-wide Authority to Your Service Account
- Get an Immutable Google Apps ID
#
Get a New Private KeyAccess your Google Service Account.
In the IAM & admin section select Service accounts.
If you need to create a new project, click CREATE do the following:
- In the New Project window, type a project name, select an organization from the drop-down list and then select a location.
- Click CREATE.
In the Service accounts section, click Create Service Account.
In the Create service account window, type a name for the service account, add a description and then click CREATE.
Click Continue.
In the Create key section, click CREATE KEY.
Select Key type JSON and click CREATE.
Click DONE.
A key pair is generated and automatically downloads.
In the Actions column, select the service and then click edit.
Under the show domain wide delegation, select Enable G Suite Domain-wide Delegation.
NOTE: Copy the value of the Unique ID for the client name in step 2 in Delegate Domain-wide Authority to Your Service Account.
Click Save.
In the top search bar, search for admin sdk.
Click Enable.
#
Delegate Domain-wide Authority to Your Service AccountAccess the Google Administrator Console.
Enter a client name and paste the following into the
One or More API Scopes
textbox.
#
GSuite API scopesAPI Scope | Description | Demisto command |
https://mail.google.com | Reads, composes, sends, and permanently deletes all of the user's emails from Gmail. |
|
https://www.googleapis.com/auth/ admin.directory.device.chromeos | Views and manages Chrome OS devices' metadata. |
|
https://www.googleapis.com/auth/ admin.directory.device.mobile.action | Manages mobile devices by performing administrative tasks. |
|
https://www.googleapis.com/auth/ admin.directory.device.mobile.readonly | Views the metadata of a mobile device. |
|
https://www.googleapis.com/auth/ admin.directory.rolemanagement | Manages delegated administration roles for the user's domain. |
|
https://www.googleapis.com/auth/ admin.directory.rolemanagement.readonly | Views delegated administration roles for the user's domain. |
|
https://www.googleapis.com/auth/ admin.directory.user | Enables full user management. |
|
https://www.googleapis.com/auth/ admin.directory.user.readonly | Views users on your domain. |
|
https://www.googleapis.com/auth/ admin.directory.user.security | Manages data access permissions for users on your domain. |
|
https://www.googleapis.com/auth/ gmail.compose | Sends a message on behalf of a user. |
|
https://www.googleapis.com/auth/ gmail.modify | Views and modifies but not deletes email. |
|
https://www.googleapis.com/auth/ gmail.readonly | Views email messages and settings. |
|
https://www.googleapis.com/auth/ gmail.send | Sends an email on behalf of someone else. |
|
https://www.googleapis.com/auth/ gmail.settings.basic | Manages basic mail settings. |
|
https://www.googleapis.com/auth/ gmail.settings.sharing | Manages sensitive email settings, including who can manage emails. |
|
#
Get an Immutable Google Apps ID ParametersIn order to revoke/fetch a user role, you need an Immutable Google Apps ID param.
Open https://admin.google.com (as in step 2).
Navigate to Security > Set up single sign-on (SSO).
The SSO URL is the Immutable Google Apps ID.Record the SSO URL, which is the Immutable Google Apps ID, and copy it for later use.
#
Configure the GoogleApps (GSuite) Integration on Demisto- Navigate to Settings > Integrations > Servers & Services.
- Search for GoogleApps API.
- Click Add instance to create and configure a new integration instance.
- Name: a textual name for the integration instance.
- Service account private key file content (JSON): Paste the Service account JSON you generated in the Google console, which includes the JSON key. The JSON might be long, so you can expand the text box.
- Email of user with admin capabilities - Enter the email address of the user that you set admin capabilities for.
- Immutable Google Apps ID: Only the Cxxxxxxxx, section is needed.
- Import emails as incidents: Automatically creates Demisto incidents from received emails.
- Events query - Use this to filter out the fetched messages.
The query language follows the Gmail query specification example: "from:someuser@example.com rfc822msgid:<somemsgid@example.com> is:unread". For more information, read the Gmail Query Language documentation. - Events user key- Use this to specify the email account to search for messages. By default, the integration uses the email address specified in the admin instance.
- Incident type
- Demisto engine
- Click Test to validate the URLs and connection.
#
CommandsYou can execute these commands from the Demisto CLI, as part of an automation, or in a playbook. After you successfully execute a command, a DBot message appears in the War Room with the command details.
- Perform an action on a Chrome device: googleapps-chrome-device-action
- Perform an action on a Google device: googleapps-device-action
- List all Chrome devices associated with a Google user: googleapps-get-chrome-devices-for-user
- List all devices associated with a Google user: googleapps-get-devices-for-user
- Get tokens for a Google user: googleapps-get-tokens-for-user
- Get information for a Google user: googleapps-get-user
- List all available Google roles: googleapps-get-user-roles
- Retrieve a Gmail message attachment: googleapps-gmail-get-attachment
- Retrieve a Gmail message: googleapps-gmail-get-mail
- Search a user's Gmail records: googleapps-gmail-search
- List all Google user: googleapps-list-users
- Revoke a Google user's role: googleapps-revoke-user-role
#
Perform an action on a Chrome devicePerforms one of several actions on a Google Chrome device.
#
Base Commandgoogleapps-chrome-device-action
#
InputParameter | Description |
customerId | Unique identifier for the customer Google account. Use the !googleapps-get-user command to get this parameter. Default is my_customer. |
action | Action to take on the Chrome OS device.
|
resource-id | Unique ID the API service uses to identify the mobile device |
token | Token for authentication and authorization |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
#
Context DataThere is no context data for this command.
#
Raw OutputAction executed.
#
Perform an action on a Google devicePerforms one of several actions on a Google device.
#
Base Commandgoogleapps-device-action
#
InputParameter | Description |
customerId | Unique identifier for the customer Google account. Use the !googleapps-get-user command to get this parameter. Default is my_customer. |
action | Action to take on the Chrome OS device.
|
resource-id | Unique ID the API service uses to identify the mobile device |
token | Token for authentication and authorization |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
#
Context DataThere is no context data for this command.
#
Raw OutputAction executed.
#
List all Chrome devices associated with a Google userLists all Google Chrome devices associated with a specified Google user.
#
Base Commandgoogleapps-get-chrome-devices-for-user
#
InputParameter | Description |
customerId | Unique identifier for the customer Google account. Use the !googleapps-get-user command to get this parameter. Default is my_customer. |
action | Action to take on the Chrome OS device.
|
resource-id | Unique ID the API service uses to identify the mobile device |
token | Token for authentication and authorization |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
#
Context Data#
Raw Output#
List all devices associated with a Google userLists all devices associated with a specified Google user.
#
Base Commandgoogleapps-get-devices-for-user
#
InputParameter | Description |
query | String to search for, enclosed in parentheses "". For more information, see the Google documentation. |
customerId | Unique identifier for the customer Google account. Use the !googleapps-get-user command to get this parameter. Default is my_customer. |
#
Context Data#
Raw Output#
Get tokens for a Google userLists all tokens associated with a specified Google user.
#
Base Commandgoogleapps-get-tokens-for-user
#
InputParameter | Description |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
#
Context Data#
Raw Output#
Get information for a Google userRetrieves information for a specified Google user.
#
Base Commandgoogleapps-get-user
#
InputParameter | Description |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
#
Context Data#
Raw Output#
List all available Google rolesLists all available Google roles for a specified Google user.
#
Base Commandgoogleapps-get-user-roles
#
InputParameter | Description |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
#
Context Data#
Raw Output#
Retrieve a Gmail message attachmentRetrieves a Gmail attachment sent to a specified Google user.
#
Base Commandgoogleapps-gmail-get-attachment
#
InputParameter | Description |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
attachment-id | ID of the attachment to retrieve |
message-id | ID of the message to retrieve |
#
Context Data#
Raw OutputRequested file.
#
Retrieve a Gmail messageRetrieves a Gmail message sent to a specified Google user.
#
Base Commandgoogleapps-gmail-get-mail
#
InputParameter | Description |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
attachment-id | ID of the attachment to retrieve |
message-id | ID of the message to retrieve |
#
Context Data#
Raw Output#
Search a user's Gmail recordsSearches the Gmail records of a specified Google user.
#
Base Commandgoogleapps-gmail-search
#
InputParameter | Description |
user-key | Email address of user that you want to search the mailbox for |
query | Only returns messages that match the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid: is:unread". For more syntax information, see the Google documentation. |
fields | Comma-separated list that enables retrieval of partial responses. For more information, see the Google documentation. |
include-spam-trash | Include messages labeled as SPAM and TRASH in the results, default is false. |
label-ids | Comma-separated list that returns only messages with labels that match all of the specified label IDs. |
max-results | Maximum number of results to return Min-Max: 1-500 Default: 100 |
page-token | Page token to retrieve a specific page of results in the list |
#
Context Data#
Raw Output#
List all Google userLists all Google users.
#
Base Commandgoogleapps-list-users
#
InputEither the domain _parameter or the _customer parameter is required.
Parameter | Description |
domain | Domain name. Use this field to get fields from only one domain. To return all domains for a customer account, use the customer query parameter. |
customer | Unique ID for the customer Google account, default is the value specified in the integration configuration |
event | Event on which subscription is intended (if subscribing). add delete makeAdmin undelete * update |
custom-feed-mask | Comma-separated list of schema names. All fields from these schemas are fetched. Only set this parameter when the projection parameter is set to custom. |
projection | The subset of fields to fetch for the specified user. basic: Do not include any custom fields for the user (default) custom: Include custom fields from schemas requested in customFieldMask * full: Include all fields associated with the specified user |
query | String to search for, enclosed in parentheses "". For more information, see the Google documentation. |
show-deleted | If true, retrieves the list of deleted users, default is false |
sort-order | How to sort the results. Ascending Descending |
token | Token to authorize and authenticate the action |
max-results | Maximum number of results to return Min-Max: 1-500 Default: 100 |
#
Context Data#
Raw Output#
Revoke a Google user's roleRevokes roles for a specified Google users.
#
Base Commandgoogleapps-revoke-user-role
#
InputParameter | Description |
role-assignment-id | Immutable ID of the role assignment |
token | Token to authorize and authenticate the action |
user-key | Identifies the user specified in the API request. The value can be the user's primary email address, alias email address, or unique user ID. |
#
Context DataThere is no context data for this command.