Skip to main content

Google Drive Component

Manage files in Google Drive

Component key: google-drive

Description

Google Drive is Google's cloud storage for work and home. This component allows you to create, copy, download, update, list, and delete files stored in a Google Drive Account.

Documentation for the Node.js client used in this component can be found at https://developers.google.com/drive/api/v3/quickstart/nodejs.

A common integration pattern involves listing files in a file store, and performing a series of actions on the array of files that are returned. See our looping over files quickstart for information about how to create a loop over an array of files.

Tracking Changes in Google Drive

To track changes within Google Drive, use the List Changes action. You can either run List Changes on a schedule with a schedule trigger (for example, check for changes every 5 minutes), or you can use Google Drive's change API to receive notifications in real time when changes occur.

For an example of how to use webhooks with Google Drive, import this example integration available on GitHub.

Connections

OAuth2

The Google Drive component authenticates requests through the Google Cloud Platform (GCP) OAuth 2.0 service. You'll need to create a GCP OAuth 2.0 app so your integration can authenticate and perform Google Drive tasks on your customers' behalf.

To create a Google Drive OAuth 2.0 app, first make sure you have a Google Developer account - you can sign up at https://console.cloud.google.com/. Then:

  1. Open up the Google Drive API console - https://console.cloud.google.com/apis/api/drive.googleapis.com
  2. Click CREATE PROJECT if you would like to create a new GCP project, or select an existing project.
  3. You will be prompted to enable Google Drive API for your project. Click ENABLE.
  4. On the sidebar, select Credentials.
  5. An OAuth 2.0 app includes a "Consent Screen" (the page that asks "Do you want to allow (Your Company) to access Google Drive on your behalf?"). Click CONFIGURE CONSENT SCREEN.
    1. Your app will be externally available to your customers, so choose a User Type of External.
    2. Fill out the OAuth consent screen with an app name (your company or product's name), support email, app logo, domain, etc.
    3. You can ignore domains for now.
    4. On the next page, add the scope https://www.googleapis.com/auth/drive.
    5. Enter some test users for your testing purposes. Your app will only work for those testing users until it is "verified" by Google. When you are ready for verification (they verify your privacy policy statement, etc), click PUBLISH APP on the OAuth consent screen. That'll allow your customers to authorize your integration to access their Google Drive.
  6. Once your "Consent Screen" is configured open the Credentials page from the sidebar again.
  7. Click +CREATE CREDENTIALS and select OAuth client ID.
    1. Under Application type select Web application.
    2. Under Authorized redirect URIs enter Prismatic's OAuth 2.0 callback URL: https://oauth2.prismatic.io/callback
    3. Click CREATE.
  8. Take note of the Client ID and Client Secret that are generated.
info

Make sure to publish your OAuth 2.0 app after you've tested it so users outside of your test users can authorize your integration to interact with Google Drive on their behalf.

Now that you have a Client ID and Client Secret, add Google Drive step to your integration in Prismatic. Open the Configuration Wizard Designer by clicking Configuration Wizard, select your Google Drive Connection and enter your client ID and secret. You will probably want to keep the default Google Drive scope, https://www.googleapis.com/auth/drive.

InputDefaultNotes
Authorize URL
string
/ Required
Hidden Field
authorizeUrl
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent
The Authorization URL for Google Drive.
Client ID
string
/ Required
clientId
The Google Drive app's Client Identifier.
Client Secret
password
/ Required
clientSecret
The Google Drive app's Client Secret.
Scopes
string
/ Required
scopes
https://www.googleapis.com/auth/drive
Space delimited listing of scopes. https://developers.google.com/identity/protocols/oauth2/scopes#drive
Token URL
string
/ Required
Hidden Field
tokenUrl
https://oauth2.googleapis.com/token
The Token URL for Google Drive.

Triggers

Push Notification Webhook

Receive and validate webhook requests from Google Drive for webhooks you configure. | key: pushNotificationWebhook

{
"payload": {
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Host": "hooks.prismatic.io",
"User-Agent": "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)",
"X-Amz-Cf-Id": "_K9KZtNN78sy1aygl3nJuQ4OoMh65STAsLFsPGENcnm_l68C112345==",
"X-Amzn-Trace-Id": "Root=1-64931762-5665c8324c471b204f212345",
"X-Goog-Channel-Expiration": "Wed, 21 Jun 2023 16:28:01 GMT",
"X-Goog-Channel-ID": "7f0419cf-5477-4bd5-bc86-2aa36af12345",
"X-Goog-Message-Number": "96035",
"X-Goog-Resource-ID": "jkkJZYhd8PPV6-Xto6QIo112345",
"X-Goog-Resource-State": "change",
"X-Goog-Resource-URI": "https://www.googleapis.com/drive/v3/changes?alt=json&pageToken=430&supportsAllDrives=true"
},
"queryParameters": null,
"rawBody": {
"data": null,
"contentType": "application/octet-stream"
},
"body": {
"data": null,
"contentType": "application/octet-stream"
},
"pathFragment": "",
"webhookUrls": {
"Flow 1": "https://hooks.prismatic.io/trigger/WEBHOOK_ID"
},
"webhookApiKeys": {
"Flow 1": [
"sample-api-key"
]
},
"invokeUrl": "https://hooks.prismatic.io/trigger/WEBHOOK_ID",
"executionId": "SW5zdGFuY2VFeGVjdXRpb25SZXN1bHQ6MGRlZjk2ZjYtYzhhOS00MDgzLWJlOTUtZmIwZDMzNDQ12345",
"customer": {
"id": "testCustomerId",
"name": "Test Customer",
"externalId": "testCustomerExternalId"
},
"instance": {
"id": "testInstanceId",
"name": "Test Instance"
},
"user": {
"id": "testUserId",
"email": "testUserEmail@example.com",
"name": "Test User",
"externalId": "testUserExternalId"
}
}
}

Data Sources

List Files

Lists all available files | key: selectFiles | type: picklist

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Drive ID
string
driveId
The ID of a shared drive to search for the file in. If not provided, the search will be performed across all drives.
0AAvGyortvuqEXAMPLE
Page Size
string
pageSize
20
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
20
Query
string
query
Provide a query to be used in the request. Refer to the Google documentation for examples: https://developers.google.com/drive/api/v3/search-files
organizerCount = 0

List Folders

Lists all available directories | key: selectFolder | type: picklist

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
Drive ID
string
driveId
The ID of a shared drive to search for the file in. If not provided, the search will be performed across all drives.
0AAvGyortvuqEXAMPLE

Select Drive

Select a drive | key: selectDrive | type: picklist

InputNotes
Connection
connection
/ Required
connection
The Connection to use for authorization.

Actions

Copy File

Copy a file by file id | key: copyFile

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
File ID
string
/ Required
fileId
A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes.
my-example-file-id
File Name
string
fileName
Provide a string for the name of the new file.
myFile
Folder ID
string
folderId
A unique opaque ID for each folder.
my-example-folder-id

{
"data": {
"name": "example",
"description": "example"
}
}

Create File

Create a new file with content and metadata | key: createFile

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder
File Content
string
/ Required
fileContent
The binary or text body of the file. Some content examples you can store in Google Drive are images, videos, text, and PDF.
My Example File Contents
File Name
string
/ Required
fileName
Provide a string for the name of the new file.
myFile
Parent Folder Id
string
folderId
A unique opaque ID for each folder.
my-example-folder-id

{
"data": {
"kind": "drive#file",
"id": "id_example",
"name": "example",
"mimeType": "example",
"description": "example"
}
}

Create Folder

Create a directory file | key: createFolder

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
Folder Name
string
/ Required
folderName
Provide a string for the name of the new folder.
Pictures
Parent Folder Id
string
parentFolderId
A unique opaque ID for each folder.
my-example-folder-id

{
"data": {
"name": "example",
"description": "example"
}
}

Create Webhook for Drive

Create a webhook to receive notifications of changes with a Google Drive | key: createDriveWebhook

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
Drive ID
string
driveId
The ID of a shared drive to search for the file in. If not provided, the search will be performed across all drives.
0AAvGyortvuqEXAMPLE
Endpoint
string
/ Required
endpoint
The URL to send notifications to
https://hooks.prismatic.io/example
Expiration Time
string
expiration
The time at which the webhook will expire as a UNIX timestamp in milliseconds. Defaults to 1 hour from now, and can be set to a maximum of 1 day from now.
1426325213000

Create Webhook for File or Folder

Create a webhook to receive notifications of changes for a file or folder | key: createFileWebhook

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
Endpoint
string
/ Required
endpoint
The URL to send notifications to
https://hooks.prismatic.io/example
Expiration Time
string
expiration
The time at which the webhook will expire as a UNIX timestamp in milliseconds. Defaults to 1 hour from now, and can be set to a maximum of 1 day from now.
1426325213000
File or Folder ID
string
/ Required
resourceId
 
ret08u3rv24htgh289g

Delete File

Delete a file by file id | key: deleteFile

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder
File ID
string
/ Required
fileId
A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes.
my-example-file-id

Delete Webhook

Stop a webhook channel from sending notifications | key: deleteWebhook

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
Resource ID
string
/ Required
resourceId
Returned when you create a webhook
ret08u3rv24htgh289g
Webhook ID
string
/ Required
webhookId
Returned when you create a webhook
00000000-0000-0000-0000-000000000000

Empty Trash

Empty the trash of deleted files | key: emptyTrash

InputNotes
Connection
connection
/ Required
connection
The Connection to use for authorization.

Get About

Gets information about the user's Drive, and system capabilities | key: getAbout

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder

{
"data": {
"user": {
"displayName": "example",
"emailAddress": "example@email.com",
"kind": "example"
}
}
}

Get Current User

Get the information and metadata of the user that is currently logged in | key: getCurrentUser

InputNotes
Connection
connection
/ Required
connection
The Connection to use for authorization.

{
"data": {
"kind": "drive#user",
"displayName": "Example User",
"photoLink": "https://lh3.googleusercontent.com/a/Example",
"me": true,
"permissionId": "12345678901234567890",
"emailAddress": "example@gmail.com"
}
}

Get File

Gets a file's metadata and content by ID. | key: getFile

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
Preferred Export Type
string
exportType
Provide the type of file you want to export as. If the value you provided is not compatible, we will attempt the first option available in the objects export types. This value is only required when exporting a non binary file.
application/x-vnd.oasis.opendocument.spreadsheet
File ID
string
/ Required
fileId
A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes.
my-example-file-id

{
"data": {
"type": "Buffer",
"data": [
101,
120,
97,
109,
112,
108,
101
]
},
"contentType": "application/octet"
}

List Changes

List changes made to files in your Google Drive since the last time this step ran (up to 1000) | key: listChanges

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
Drive ID
string
driveId
The ID of a shared drive to search for the file in. If not provided, the search will be performed across all drives.
0AAvGyortvuqEXAMPLE

The first time this action runs, it takes note of the current pageToken returned by Google, and returns no changes. Subsequent runs of this step use that pageToken to determine what has changed since the last time this step ran.

{
"data": {
"kind": "drive#changeList",
"newStartPageToken": "247040",
"changes": [
{
"kind": "drive#change",
"removed": false,
"file": {
"kind": "drive#file",
"mimeType": "image/png",
"id": "14FSE_ESVGWta4XlzWGHVm0VultNS-1uO",
"name": "example.png"
},
"fileId": "14FSE_ESVGWta4XlzWGHVm0VultNS-1uO",
"time": "2022-09-20T21:36:23.687Z",
"type": "file",
"changeType": "file"
}
]
},
"instanceState": {
"example-step-id": "example-new-page-token"
}
}

List Drives

List all drives | key: listDrives

InputNotes
Connection
connection
/ Required
connection
The Connection to use for authorization.

List File's Export Types

List the available export types of a file by ID. | key: listExportTypes

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
File ID
string
/ Required
fileId
A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes.
my-example-file-id

{
"data": [
"application/x-vnd.oasis.opendocument.spreadsheet",
"text/tab-separated-values",
"application/pdf",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"text/csv",
"application/zip",
"application/vnd.oasis.opendocument.spreadsheet"
]
}

List Files

Lists all available files and directories | key: listFiles

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Drive ID
string
driveId
The ID of a shared drive to search for the file in. If not provided, the search will be performed across all drives.
0AAvGyortvuqEXAMPLE
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder
Page Size
string
pageSize
20
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
20
Page Token
string
pageToken
Specify the pagination token that's returned by a previous request to retrieve the next page of results
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E
Query
string
query
Provide a query to be used in the request. Refer to the Google documentation for examples: https://developers.google.com/drive/api/v3/search-files
organizerCount = 0

{
"data": {
"files": [
{
"name": "example",
"description": "example"
}
]
}
}

List Folders

Lists all available directories | key: listFolders

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Drive ID
string
driveId
The ID of a shared drive to search for the file in. If not provided, the search will be performed across all drives.
0AAvGyortvuqEXAMPLE
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder
Folder ID
string
folderId
A unique opaque ID for each folder.
my-example-folder-id
Page Size
string
pageSize
20
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
20
Page Token
string
pageToken
Specify the pagination token that's returned by a previous request to retrieve the next page of results
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E

{
"data": {
"files": [
{
"name": "example",
"description": "example"
}
]
}
}

Move File

Move a file by file ID | key: moveFile

InputNotesExample
Connection
connection
/ Required
connection
The Connection to use for authorization.
 
File ID
string
/ Required
fileId
A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes.
my-example-file-id
Folder ID
string
/ Required
folderId
A unique opaque ID for each folder.
my-example-folder-id

{
"data": {
"name": "example",
"description": "example"
}
}

Raw Request

Send raw HTTP request to Google Drive | key: rawRequest

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Data
string
data
The HTTP body payload to send to the URL.
{"exampleKey": "Example Data"}
Debug Request
boolean
debugRequest
false
Enabling this flag will log out the current request.
 
File Data
string
Key Value List
fileData
File Data to be sent as a multipart form upload.
[{key: "example.txt", value: "My File Contents"}]
File Data File Names
string
Key Value List
fileDataFileNames
File names to apply to the file data inputs. Keys must match the file data keys above.
 
Form Data
string
Key Value List
formData
The Form Data to be sent as a multipart form upload.
[{"key": "Example Key", "value": new Buffer("Hello World")}]
Header
string
Key Value List
headers
A list of headers to send with the request.
User-Agent: curl/7.64.1
Max Retry Count
string
maxRetries
0
The maximum number of retries to attempt.
 
Method
string
/ Required
method
The HTTP method to use.
 
Query Parameter
string
Key Value List
queryParams
A list of query parameters to send with the request. This is the portion at the end of the URL similar to ?key1=value1&key2=value2.
 
Response Type
string
/ Required
responseType
json
The type of data you expect in the response. You can request json, text, or binary data.
 
Retry On All Errors
boolean
retryAllErrors
false
If true, retries on all erroneous responses regardless of type.
 
Retry Delay (ms)
string
retryDelayMS
0
The delay in milliseconds between retries.
 
Timeout
string
timeout
The maximum time that a client will await a response to its request
2000
URL
string
/ Required
url
Input the path only (/files), The base URL is already included (https://www.googleapis.com/drive/v3). For example, to connect to https://www.googleapis.com/drive/v3/files, only /files is entered in this field.
/files
Use Exponential Backoff
boolean
useExponentialBackoff
false
Specifies whether to use a pre-defined exponential backoff strategy for retries.
 

Search Files

Search for an existing file by Name | key: searchFiles

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder
Files Containing Search Query
boolean
filesContainingSearchQuery
Wether or not to search for files that contains the provided 'searchQuery' in their name.
 
Parent Folder Id
string
folderId
A unique opaque ID for each folder.
my-example-folder-id
Page Size
string
pageSize
20
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
20
Page Token
string
pageToken
Specify the pagination token that's returned by a previous request to retrieve the next page of results
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E
Query
string
query
Provide a query to be used in the request. Refer to the Google documentation for examples: https://developers.google.com/drive/api/v3/search-files
organizerCount = 0
Search
string
searchQuery
Provide a string of text to perform a search with.
Search for this string

Search Folders

Search for an existing directory by Name | key: searchFolders

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder
Parent Folder Id
string
folderId
A unique opaque ID for each folder.
my-example-folder-id
Page Size
string
pageSize
20
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
20
Page Token
string
pageToken
Specify the pagination token that's returned by a previous request to retrieve the next page of results
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E
Search
string
searchQuery
Provide a string of text to perform a search with.
Search for this string

{
"data": {
"files": [
{
"name": "example",
"description": "example"
}
]
}
}

Update File

Updates a file's content by file id | key: updateFile

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
The Connection to use for authorization.
 
Fields
string
fields
*
Provide a comma separated list of values to be returned in the response.
ParentFolder
File Content
string
fileContent
The binary or text body of the file. Some content examples you can store in Google Drive are images, videos, text, and PDF.
My Example File Contents
File ID
string
/ Required
fileId
A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes.
my-example-file-id
File Name
string
fileName
Provide a string for the name of the new file.
myFile

{
"data": {
"kind": "drive#file",
"id": "id_example",
"name": "example",
"mimeType": "example",
"description": "example"
}
}