Google Drive v2
Provides integration with Google Drive, the cloud file storage and sharing service, through the Google Drive API v3.
Use this Node to work with files and folders from a Workflow, for example to search for files, download or export documents, upload files from other systems, move or copy files between folders, or share files. The Node also covers shared drives, permissions, revisions, comments, replies and file labels.
Revision History
0.0.0.1 - Initial release.
Connection
The Connection authenticates as a Google user through OAuth, or as a Google service account.
| Property | Type | Description |
|---|---|---|
AuthenticationType |
Enum | OAuth for a Google user or ServiceAccount for a service-account key. The default is OAuth. |
ClientId |
String | OAuth client ID from a Google Cloud project with the Drive API enabled. Used with OAuth. |
ClientSecret |
Masked | OAuth client secret from Google Cloud. Used with OAuth. |
AccessToken |
Masked | Populated when you connect the account and renewed automatically. A token entered on its own cannot be renewed. Used with OAuth. |
RefreshToken |
Masked | Populated when you connect the account. Used with OAuth. |
ClientEmail |
String | client_email value from the service-account key file. Used with ServiceAccount. |
PrivateKey |
Masked | private_key value from the service-account key file. Escaped \n line breaks are accepted. Used with ServiceAccount. |
Subject |
String | Optional Google Workspace user to act as through domain-wide delegation. Used with ServiceAccount. |
TimeoutSeconds |
Integer | Timeout for each request, in seconds. The default is 100. |
Setup Notes
This Node runs on the Cloud Cluster.
For OAuth:
- In Google Cloud, create or choose a project, enable the Google Drive API, and create an OAuth client. Add the Flowgear OAuth callback URL,
https://app.flowgear.net/r/auth, to the client's authorized redirect URIs. - Create a Connection for
Google Drive, setAuthenticationTypetoOAuth, and enterClientIdandClientSecret. - Click
Connect Accountand sign in with the Google user whose files the Workflow should reach. - Test and save the Connection.
The Node requests the full https://www.googleapis.com/auth/drive scope, because narrower scopes cannot list, search, or share existing files. Google classes this scope as restricted, so a public OAuth app needs Google's restricted-scope verification. An internal app, or an app in testing mode with listed test users, works without it.
For ServiceAccount:
- In Google Cloud, enable the Google Drive API and create a service-account key in JSON format.
- Create a Connection, set
AuthenticationTypetoServiceAccount, and copyclient_emailandprivate_keyfrom the key file intoClientEmailandPrivateKey. - Share the files, folders, or shared drives the Workflow needs with
ClientEmail, or setSubjectto a Workspace user and grant the service account domain-wide delegation for thehttps://www.googleapis.com/auth/drivescope. - Test and save the Connection.
A service account has no Drive storage of its own. Without Subject, uploading a file or creating a Google Docs file in a My Drive fails with storageQuotaExceeded. Folders and files without content can still be created.
Methods
Select a template for each Step. Templates supply OperationId and the inputs for the selected Drive operation, using Google's field names.
Get
Gets one record, such as a file, shared drive, permission, revision, comment, or reply, or the signed-in user's account details.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Options |
Object | IDs of the record, such as fileId, and an optional fields selector. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row containing the record. |
List
Lists files, shared drives, permissions, revisions, comments, replies, or file labels.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Options |
Object | Parent IDs, such as fileId for List Permissions, optional filters, and an optional fields selector. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row per record, across every page. An empty result returns zero rows. |
List Files with no filters returns every file the Connection can see, including trashed files.
Search
Searches files or shared drives with Google's query syntax.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Options |
Object | Required q query, such as name contains 'invoice' and trashed = false, plus optional search scope values and fields selector. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row per matching record, across every page. No matches return zero rows. |
A Search Step with an empty q fails. Use List to read every record.
Download
Downloads a file or a kept revision, or exports a Google Docs, Sheets, or Slides file to another format.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Options |
Object | fileId, plus revisionId for a revision or the export mimeType, such as application/pdf. |
| Return | Type | Description |
|---|---|---|
Content |
Stream | The file, revision, or export content. |
ContentType |
String | Media type Google returned for the content. |
Create
Creates files without content, folders, shared drives, permissions, comments, or replies.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Items |
Array | One record per item, with every ID it needs, such as fileId for a permission. Create Shared Drive also needs a unique requestId on each item. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row per item: the Google record plus a Flowgear object with IsSuccess, Message, and Request. |
Update
Updates files, permissions, shared drives, revisions, comments, or replies. Update File also moves a file with addParents and removeParents, and moves it to the trash with trashed set to true.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Items |
Array | One record per item, with its IDs and the fields to change. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row per item: the Google record plus a Flowgear object with IsSuccess, Message, and Request. |
Delete
Permanently deletes files, permissions, shared drives, revisions, comments, or replies.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Items |
Array | One item per record to delete, with its IDs. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row per item with a Flowgear object containing IsSuccess, Message, and Request. |
Delete File skips the trash and cannot be undone. Use Update File with trashed set to true when the file should stay recoverable.
Action
Copies files, changes the labels on a file, or hides and unhides shared drives.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Items |
Array | One record per item, with its IDs. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row per item: the Google record plus a Flowgear object with IsSuccess, Message, and Request. |
Upload
Uploads a new file or replaces the content of an existing file, up to 5 MB per file.
| Parameter | Type | Description |
|---|---|---|
Connection |
Connection | Google Drive Connection to use. |
OperationId |
String | Operation selected by the template. |
Items |
Array | One file per item: file fields such as name and parents, the file content as base64 text in Content, and an optional ContentType, such as application/pdf. Replace File Content also needs fileId. |
| Return | Type | Description |
|---|---|---|
Response |
Array | One row per item: the Google file plus a Flowgear object with IsSuccess, Message, and Request. |
When ContentType is empty, the file's mimeType is used, and otherwise application/octet-stream.
Usage Notes
Create,Update,Delete,Action, andUploadsend one request per item. A failure on the first item fails the Step. A failure on a later item returns a row withFlowgear.IsSuccessset tofalse, and later items still run. A failed row includes Google'serrorobject, so later Steps can branch onerror.errors[0].reason.- Writes are not retried after a server error or timeout, because Google may have applied them. Check Google Drive before sending that item again.
- A field mapped as null is not sent. To clear a text field, send an empty string.
Get,List, andSearchaccept an optionalfieldsselector, such asid,name,mimeType, to return fewer fields. When it is empty, every field is returned, which is slower.- Files in shared drives are reachable. To list or search one shared drive, set
driveId,corporatodrive, andincludeItemsFromAllDrivestotrue. - Lists of text values, such as
parents, use comma-separated values. Quote a value that contains a comma, and an empty value is an empty list. Free-form maps, such asproperties, use JSON text. - Google limits export output to 10 MB, and serves revision content only for revisions marked Keep Forever.
Known Issues
- Uploads are limited to 5 MB per file.
- Downloads are read whole into memory before the
Contentstream is returned. - Change notifications, the change feed, emptying the trash, and Drive label definitions are not supported.