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.

Google Drive 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, ignore scopes - this component knows what scopes it needs to run and will request the right scopes for you.
    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 Config Variables drawer, 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
Input
Authorize URL
string
/ Required
Hidden Field
Default
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&prompt=consent
Notes
The Authorization URL for Google Drive.
Input
Client ID
password
/ Required
Default
 
Notes
The Google Drive app's Client Identifier.
Input
Client Secret
password
/ Required
Default
 
Notes
The Google Drive app's Client Secret.
Input
Scopes
string
/ Required
Default
https://www.googleapis.com/auth/drive
Notes
Space delimited listing of scopes. https://developers.google.com/identity/protocols/oauth2/scopes#drive
Input
Token URL
string
/ Required
Hidden Field
Default
https://oauth2.googleapis.com/token
Notes
The Token URL for Google Drive.

Actions#

Copy File#

Copy a file by file id | key: copyFile

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

Output Example Payload#

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

Create File#

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

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

Output Example Payload#

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

Create Folder#

Create a directory file | key: createFolder

InputNotesExample
Input
Connection
connection
/ Required
Notes
The Connection to use for authorization.
Example
 
Input
Folder Name
string
/ Required
Notes
Provide a string for the name of the new folder.
Example
Pictures

Output Example Payload#

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

Delete File#

Delete a file by file id | key: deleteFile

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

Empty Trash#

Empty the trash of deleted files | key: emptyTrash

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

Get About#

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

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

Output Example Payload#

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

Get File#

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

InputNotesExample
Input
Connection
connection
/ Required
Notes
The Connection to use for authorization.
Example
 
Input
Preferred Export Type
string
Notes
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.
Example
application/x-vnd.oasis.opendocument.spreadsheet
Input
File ID
string
/ Required
Notes
A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes.
Example
my-example-file-id

Output Example Payload#

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

List File's Export Types#

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

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

Output Example Payload#

{  "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
Input
Connection
connection
/ Required
Default
 
Notes
The Connection to use for authorization.
Example
 
Input
Fields
string
Default
*
Notes
Provide a comma separated list of values to be returned in the response.
Example
ParentFolder
Input
Page Size
string
Default
 
Notes
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
Example
20
Input
Page Token
string
Default
 
Notes
Specify the pagination token that's returned by a previous request to retrieve the next page of results
Example
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E
Input
Query
string
Default
 
Notes
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
Example
organizerCount = 0

Output Example Payload#

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

List Folders#

Lists all available directories | key: listFolders

InputDefaultNotesExample
Input
Connection
connection
/ Required
Default
 
Notes
The Connection to use for authorization.
Example
 
Input
Fields
string
Default
*
Notes
Provide a comma separated list of values to be returned in the response.
Example
ParentFolder
Input
Folder ID
string
Default
 
Notes
A unique opaque ID for each folder.
Example
my-example-folder-id
Input
Page Size
string
Default
 
Notes
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
Example
20
Input
Page Token
string
Default
 
Notes
Specify the pagination token that's returned by a previous request to retrieve the next page of results
Example
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E

Output Example Payload#

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

Raw Request#

Issue a raw HTTP request with the configured connection | key: rawRequest

InputDefaultNotesExample
Input
Connection
connection
/ Required
Default
 
Notes
The Connection to use for authorization.
Example
 
Input
Data
string
Default
 
Notes
The HTTP body payload to send to the URL. Must be a string or a reference to output from a previous step.
Example
{"exampleKey": "Example Data"}
Input
Debug Request
boolean
Default
 
Notes
Enabling this flag will log out the current request.
Example
 
Input
File Data
string
Key Value List
Default
 
Notes
File Data to be sent as a multipart form upload.
Example
[{key: "example.txt", value: "My File Contents"}]
Input
Form Data
string
Key Value List
Default
 
Notes
The Form Data to be sent as a multipart form upload.
Example
[{"key": "Example Key", "value": new Buffer("Hello World")}]
Input
Header
string
Key Value List
Default
 
Notes
A list of headers to send with the request.
Example
User-Agent: curl/7.64.1
Input
Max Retry Count
string
Default
0
Notes
The maximum number of retries to attempt.
Example
 
Input
Method
string
Default
 
Notes
 
Example
 
Input
Query Parameter
string
Key Value List
Default
 
Notes
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.
Example
 
Input
Response Type
string
Default
json
Notes
The type of data you expect in the response. You can request json, text, or binary data.
Example
binary
Input
Retry Delay (ms)
string
Default
0
Notes
The delay in milliseconds between retries.
Example
 
Input
Retry On All Errors
boolean
Default
false
Notes
If true, retries on all erroneous responses regardless of type.
Example
 
Input
Timeout
string
Default
 
Notes
The maximum time that a client will await a response to its request
Example
2000
Input
URL
string
/ Required
Default
 
Notes
This is the URL to call.
Example
/sobjects/Account
Input
Use Exponential Backoff
boolean
Default
false
Notes
Specifies whether to use a pre-defined exponential backoff strategy for retries.
Example
 

Search Files#

Search for an existing file by Name | key: searchFiles

InputDefaultNotesExample
Input
Connection
connection
/ Required
Default
 
Notes
The Connection to use for authorization.
Example
 
Input
Fields
string
Default
*
Notes
Provide a comma separated list of values to be returned in the response.
Example
ParentFolder
Input
Parent Folder Id
string
Default
 
Notes
A unique opaque ID for each folder.
Example
my-example-folder-id
Input
Page Size
string
Default
 
Notes
Provide an integer value for the maximum amount of results that will be returned. Provide a value from 1 to 50.
Example
20
Input
Page Token
string
Default
 
Notes
Specify the pagination token that's returned by a previous request to retrieve the next page of results
Example
lslTXFcbLQKkb0vP9Kgh5hy0Y0OnC7Z9ZPHPwPmMnxSk3eiDRMkct7D8E
Input
Query
string
Default
 
Notes
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
Example
organizerCount = 0
Input
Search
string
Default
 
Notes
Provide a string of text to perform a search with.
Example
Search for this string

Search Folders#

Search for an existing directory by Name | key: searchFolders

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

Output Example Payload#

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

Update File#

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

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

Output Example Payload#

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