Connectors / Service / Google Drive

Get access to files anywhere through secure cloud storage and file backup for your photos, videos, files and more (updated: 1657714865486)

Google Drive

Send and retrieve data from Google Drive

Overview

Get access to files anywhere through secure cloud storage and file backup for your photos, videos, files and more.

API INFO: The Base URL used for the Google Drive connector is https://www.googleapis.com/drive/v3. More information can be found on their main API documentation (v3) site.

Authentication

Within the workflow builder, highlight the Google Drive connector.

In the Google Drive connector properties panel (to the right of the builder), click on the Authenticate tab and the 'Add new authentication' button.

google-drive-auth-page

This will result in a Tray.io authentication pop-up modal. The first page will ask you to name your authentication and select the type of authentication you wish to create ('Personal' or 'Organisational').

The next page asks you to set the scopes you wish your authentication to have access to. Select these depending on your project needs.

google-drive-scopes

Once you have set these fields to your Tray.io authentication popup window, click the 'Create authentication' button.

Go back to your settings authentication field (within the workflow builder properties panel), and select the recently added authentication from the dropdown options now available.

Your connector authentication setup should now be complete.

Note on Operations usage

Google Drive is NECESSARY to List Available Spreadsheets

IMPORTANT!: From now on the Google Drive connector is needed in order to be able to List Available Spreadsheets of a user. It is HIGHLY RECOMMENDED that the Google Drive connector be placed near the top of any new Google Sheets connector based workflow.

Previously we included the ability to get a list of users spreadsheets from within the Google Sheets connector itself. Regardless of this, behind the scenes it has always been a separate task, actually stemming from the Google Drive connector itself.

Due to new security updates from Google, this feature now needs to be spilt in its entirety. This update effectively breaks all and any previous workflows that were dependent upon this ability within the Google Sheets connector.

There are 2 ways to navigate this issue:

  1. You can connect a new Google Drive connector to an earlier point withing your current workflow, and set it up in such as way so as to list all the current available spreadsheets found in conjunction with your Google Sheets user.

  2. If you have individual sheets in mind, and you know the Google Sheet ID, you can utilise that ID by putting it directly into the relevant Google Sheet operation field, where needed. In order to find the sheet ID, you need only look at the Google Sheet URL, and copy the hash found between the d/ and the /edit sections.

As the Google Drive connector holds most of the permissions available for downloading Google files (regardless of type) - it is recommended to try revising your workflow to include this connector, should you face any Google file downloading issues.

Download file types

IMPORTANT!: If you are downloading a Google file then please be sure to use the 'Download Google file' operation. This is not the same as simply downloading a file form within your Google Drive.

Note that your Google Drive download will fail if the file type you are downloading is not accurately set.

  • Download Google file: Best used when you wish to export a Google document for use in other services or programme (such as MS word etc).

VS

  • Download file: Best used when downloading a file from your Drive that is in a unrecognised file format, one that Google Drive does not support. Despite not having a recognised format, this operation will be able to download a file based off its Google file ID. This is found in the URL of the file in question.

Example Usage

TRAY POTENTIAL: Tray.io is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with Tray.io and the google-drive connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Below is an example of a way in which you could potentially use the Google Drive connector, to get the File ID from a drive file and download said file for later use.

The steps will be as follows:

  1. Setup using a manual trigger and add a Google Drive connector to the workflow.

  2. Once all files are listed, download said file.

  3. Use the CSV Editor to download the specified file.

Your completed workflow should look similar to this:

google-drive-complete-workflow

1 - Setup Trigger & List files

With your trigger in place (be it Manual, Scheduled, Callable etc) add a Google Drive connector. Set the operation to 'List files'.

Your 'Source' property will depend on your Drive structure and where the file you wish to download is based. In this case we have selected 'user' from the dropdown options available.

Note that the 'Drive ID' is only required if the aforementioned 'Source' is set to 'Drive'.

In order to speed up the query, select and set both of the filter options available, aka: 'Filter by Folder' and 'Filter by Name'.

Feel free to re-name your steps as you go along to make things clearer for yourself and other users. The operation names themselves often suffice.

google-drive-step-1

Now when the workflow is triggered, it will run a search query to find all the available files found within the specified source folder. In this case we already knew the name of the file that we wished to download as well, which speeds the investigation up further.

2 - Download file

Add another Google Drive connector into your workflow as your next step. Set your operation to 'Download Google file'.

In order to specify the list you want to collect your 'File ID' from, start by using the list mapping icon (found next to the list input field, within the properties panel) to generate the connector-snake.

While hovering over the 'Get File ID from Drive' step (with the tail end of the connector-snake), select your file from the list of output properties displayed. This will auto-populate a jsonpath within your list input field, and update the type selector to jsonpath.

In this case, the name of the file we wished to download was already known and only returned a single result. You may wish to consider using the Loop connector if your results return an array of results instead.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray.io, please see our Intro page and Data Guide for more details.

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

google-drive-step-2

For more clarification on the pathways you have available, open the Debug panel to view your step's Input and Output. When run, you will be able to see a URL is returned in the Output panel. Users can navigate to this URL to download a copy of the file locally should they wish to.

google-drive-step-2-url

3 - Create temp CSV

Using a CSV Editor step, set the operation to 'Create CSV From File'. The file is only needed for short term storage so we set the 'Scope' to 'Current run'.

The 'File URL' is gleaned using the same connector-snake method from earlier.

google-drive-step-3

When run the workflow will now create a simple CSV file from the original Google file. One that remains in scope and can be manipulated and edited within and across workflows.

Checkout the Output panel once more to see the column headers of the temporary CSV file in question. They should correlate to the the original Google file.

google-drive-step-3-output

BEST PRACTICES: Whenever you do decide to create your own workflow, be sure to check out some of our key articles such as:

All Operations

Latest version:

3.0

Create folder

Create a folder.

Create permission

Create permission for a file

Delete permission

Delete permission from a file

Download Google file

Export and download a Google file by ID. Use this if you want to export a Google Doc for use in other programs, like Microsoft Word or Excel.

Download file

Download a file by ID.

Duplicate file

Duplicate a file.

Get file details

Get details about a file by specifying its ID.

Get permission

Get permission.

Get start page token

Get the starting pageToken to use in list changes.

List changes

List the changes for a user or shared drive.

List drives

List drives.

List drives DDL

List files

Retrieve a list of files.

List folders DDL

List permissions

List permissions.

List spreadsheets

A list of the currently authenticated user's spreadsheets

Move file

Move a file or folder into another folder.

Update permission

Update permission for a file

Upload file

Upload a file.

Create a Google document

Create a blank Google document in yours or your teams' drive.

Delete file

Delete a file by specifying its ID.