Google Drive

Valuable for offsite file backups, team-wide storage, and document collaboration, Google Drive can be an important part of any team workflow. Skuid’s Google Drive data source type makes it easier than ever to access files stored within Drive and utilize that data within a Skuid page.

Configuration

As with any Google data source type, you must first create a Google project within the Google API Manager to receive a client ID and client secret, as shown above. Once you’ve created a Google project, enable the Google Drive API in that project.

After doing so, you’ll need to configure a Skuid data source to use your newly enable API in Skuid:

Create the Google Drive data source

  1. Navigate to Configure > Data Sources > Data Sources.
  2. Click New Data Source.
  3. Select the GoogleDrive data source type.
  4. Enter a unique name for your data source, such as GoogleDrive.

Note

The name for the data source must not have spaces. Spaces in the data source name may cause unexpected behaviors.

  1. Click Next Step.
  2. Select the authentication provider you created in the previous section.
  3. Click Save new Data Source.
  4. If Skuid asks to create a Remote Site Setting, click OK.

You can now select your Google Drive data source within a model in the Composer.

Usage

Google Drive is a unique data source because the main model entity (the data object) is File. Due to Google Drive’s unique structure, even folders themselves are simply files with a specific media (or MIME) type. Files are organized into folders by metadata tags, as opposed to the standard directory tree structure. Because of this, all Google Drive models point to the Files entity.

Note

All of the following conditions are applied as a contains searches instead of exact matches.

For example, a 'Title' = 'My File' condition will return all of the following results:

  • My File
  • My File 2
  • My File - Updated Draft

Every Google Drive model generates three default conditions:

  • Parent Folder: If your Skuid page will be working primarily in one directory, then you may enter its ID here.
    • By default this condition is set to root, which is the topmost of level of your Google Drive.
  • Title: Related to the actual title of the file.
  • Mimetype: Related to the media or file type. For a full list of usable MIME types, see Google’s Supported MIME Types page. However, this model condition accepts the following contextually-named values:
    • folder: Returns Google Drive folders.
    • image: Returns images, such as png files.
    • document: Returns documents, such as docx files.

Using these model conditions, you can use two or more models:

  1. A model that pulls strictly folder data, commonly named Folders.

    • Set the value for your mimetype condition to folder.

      Note

      Since Google Drive folders are actually files themselves, this condition will force the model to only accept files that are folders.

    • Pull at least the following fields:

      • Title
      • Id
      • Mime Type
  2. A model that gathers all file data, commonly named Files.

    • Pull at least the following fields:
      • Title
      • Id
      • Mime Type

These two models will handle most basic use cases.

Note

If you would prefer your Parent Folder condition point to a specific folder within Google Drive, navigate to that folder within your browser and copy the URL. It should look something like this:

1
https://drive.google.com/drive/folders/0B8fR0ko3BAUiWThJRDlYTjdSRyc

The final part of that URL is the folder ID, which you can use in your model condition.

Data Source Actions

The Google Drive data source currently features one data source action: Create new. This action is capable of generating several types of files—including folders—in Google formats.

This data source action has several fields:

  • Model with Parent Folder Condition: The model selected here will determine where your new file is created within Google Drive based on its Parent Folder condition.
  • File Name: Enter the name of the new file here. Compatible with merge syntax, you could use this field in conjunction with the Action Framework to create contextually useful files.
  • File Type: Here you can select an array of Google formats for your new file.
    • Folder
    • Document
    • Spreadsheet
    • Slides
    • Form
    • Drawing

Because of its flexibility, this data source action can actually automate several processes when handling business data.

  • Using a model action, generate a new folder—using merge syntax—for each new account you create, allowing for easy, automated organization of business materials.
  • Create Google forms for customer feedback directly from a table.
  • Generate Google documents for shared notes on opportunities

And these are just a few examples. Experiment with this feature to find something relevant to your use case.

Uploading Files

You may also use the File Upload component with any Google Drive model to upload files to Drive. If you select a Google Drive model for your File Upload component’s Parent Model property, the following fields will appear:

File Storage Location: Direct Upload

This default value simply means files will be placed within the directory of the Parent Model. This value the cannot be changed.

Label: Entering a label will insert custom text for the upload button. Leaving this field blank will result in a button that simply says Upload.

File Name: Use this field to rename any files uploaded through the file component.

This field is compatible with :ref`merge syntax <merge-syntax>`.

If this field is blank, files will retain their original name.

Using a dot within this field will cause the file type to overwritten as well.

Snippet to Run on Completion: Enter the name of any JavaScript snippets you wish to run once a file has been uploaded to Drive.

Files will be uploaded in the directory set by the Parent Folder condition of the Parent Model.

Troubleshooting

Request to data source “<Your data source name>” failed: Access Not Configured. [[]]

You may not have enabled the Drive or Calendar API in your Google project. You can visit the link noted in the error message to quickly enable the API, or you can visit Google’s API Manager to do so. If you have enabled your API, note that it will take several minutes for your changes to propagate Google’s systems.

401 error: Error: deleted_client [[]]

If you see this error in your authentication popup, that means the OAuth credentials you created in your Google Project have been deleted. Return to the API Console to create a set, and then update your authentication provider to match.

If your page is stuck on the “Loading…” message [[]]

This may mean the scope is not provided when authenticating. While Skuid will often fill in your default scopes, you can try adding scopes in the Default Scopes field in your authentication provider. To do so, insert https://www.googleapis.com/auth/calendar and https://www.googleapis.com/auth/drive in the Default Scopes field, separated by a space.

Authentication modal appears after page refresh [[]]

If an authentication modal appears every time the end user visits a page, the cause may be the name of the data source. Spaces in the name of a Google data source trigger the authentication modal when loading a page with a model connected to that data source. To change the name of the data source, go to DATA SOURCES > select the Google data source from the list > General > Name and remove spaces from the data source name. Click Save to confirm the change.