Google: Service Account
Using service accounts is more complex than OAuth2. Before you begin:
- Check if your node is compatible with Service Account.
- Make sure you need to use service account. For most use cases, OAuth2 is a better option.
- Read the Google documentation on Creating and managing service accounts.
Prerequisites
Set up Service Account
Create a new credential in Robbot Automation
Follow the steps to Create a credential.
!!! note "Generic and specific credentials" If you create a credential by selecting Create new in the credentials dropdown in a node, Robbot Automation automatically creates the correct credential type for that node. If you select Credentials > New, you must browse for the credential type:
* To connect with a specific service, using resources and operations supported by Robbot Automation, choose that service. For example, to create a credential for use in the Gmail node, search for `Gmail`.
* To create a credential for a [custom API call](/integrations/custom-operations/), select **Google API**.Note the Private Key from the node credential modal. You'll need this in the next section.
Set up service account in Google Cloud
In your Google Cloud Console dashboard:
Select the hamburger menu > APIs & Services > Credentials. Google takes you to your Credentials page.
??? Details "View screenshot"
Select + CREATE CREDENTIALS > Service account.
??? Details "View screenshot"
Enter a name in Service account name, and an ID in Service account ID. Refer to Creating a service account for more information.
Select CREATE AND CONTINUE.
Based on your use-case, you may want to Select a role and Grant users access to this service account using the corresponding sections.
Select DONE.
Select your newly created service account under the Service Accounts section. Open the KEYS tab.
Select ADD KEY > Create new key.
??? Details "View screenshot"
In the modal that appears, select JSON, then select CREATE. Google saves the file to your computer.
Enable each Google service API that you want to use: --8<-- "_snippets/credentials/google/enable-apis.md"
Create and test your connection
In Robbot Automation:
- In the Service Account Email field, enter the email associated with your new Service Account (you can find this in the Details tab in Google Cloud).
- Enter the Private Key from the downloaded JSON file. If you're running an Robbot Automation version older than 0.156.0: replace all instances of
\n
in the JSON file with new lines. - Optional: Click the toggle to enable Impersonate a User and enter the email.
- Save your credentials.
Troubleshooting
Service Account cannot access Google Drive files
A Service Account can't access Google Drive files and folders that weren't shared with its associated user email.
- Access your Google Cloud Console and copy your Service Account email.
- Access your Google Drive and go to the designated file or folder.
- Right-click on the file or folder and select Share.
- Paste your Service Account email into Add People and groups.
- Select Editor for read-write access or Viewer for read-only access.