To set up a Google Drive connector, you need to configure it to connect to your Google Drive account. This involves granting the connector permission to access your Drive files and folders.
The connector can be configured to sync files and folders from specific labels or folders in your Google Drive account. You can also choose to sync files and folders from all accounts or specific accounts.
To manage the Google Drive connector, you can view the sync history and check for any errors or issues. This can help you troubleshoot any problems that may arise during the sync process.
Pre-Requisites
To set up the Google Drive connector, you'll need a few things in place. You'll need a fully functional Globus Connect Server 5 endpoint, which is a given if you're reading this article.
You'll also need a Google account to complete the registration process. This account will be used solely for registration and won't affect any Google accounts you plan to use with the endpoint. An administrator can use an existing Google account for this purpose.
Here are the specific requirements for the Google Drive connector:
- HTTPS for the Incorta Cluster
- G Suite account
- Google API Project with both the Google Drive API and the Google Sheets API enabled
Make sure you have these prerequisites covered before moving forward with the setup process.
Configuration
To configure the Google Drive Connector, you'll need to encrypt configuration information with a secret key on the node servicing the request. This key is only available locally to the node and is secured such that only the node admin has access.
All configuration information, including Google Drive secrets and user credential information, is stored locally and uploaded to GCS cloud services for distribution to other nodes in the endpoint.
You'll need to restart the Analytics Service, Loader Service, and any add-ons such as the Notebook Service after configuration.
To specify the required properties for the Default Tenant Configuration, follow these steps:
- Sign in to the CMC.
- In the Navigation bar, select Clusters.
- In the cluster list, select a Cluster name.
- In the canvas tabs, select Cluster Configurations.
- In the panel tabs, select Default Tenant Configurations.
- In the left pane, select Integration.
- In the right pane, specify your Client ID in Google Drive Client ID.
- Your Client Secret in Google Drive Client Secret.
- Select Save.
You'll also need to specify the client credentials for a specific tenant. This involves signing in to the CMC and following similar steps.
To obtain the necessary OAuth token, follow the steps outlined in the appendix. This will allow you to read and create a folder and/or files from a desired Google Drive instance.
You can apply a Connector to a task or event via the append menu. For example, you can use the --google-client-id and --google-client-secret command-line options to configure Globus Connect Server to authenticate with Google Drive Connector.
Storage and Policies
The Google Drive Connector has policies to manage application credentials and set the user API rate quota. This ensures that your application interacts with Google Drive in a controlled and efficient manner.
You can manage these policies through the Google Drive Connector's storage gateway policies, which come in different schemas, such as GoogleDriveStoragePolicies_1_0_0 and GoogleDriveStoragePolicies_1_1_0. These schemas provide a structured way to define and manage your storage gateway policies.
Here are the available storage gateway policy schemas:
- GoogleDriveStoragePolicies_1_0_0
- GoogleDriveStoragePolicies_1_1_0
Storage Policies
Storage policies are a crucial aspect of managing your storage gateway, and for Google Drive, there are specific policies to be aware of.
To create a storage gateway for Google Drive, you'll need to use the command `globus-connect-server storage-gateway create google-drive`. This command will help you set up the foundation for managing your storage gateway.
The Google Drive Connector has policies to manage application credentials, and set the user API rate quota. This is essential for ensuring your storage gateway runs smoothly and efficiently.
You'll also need to familiarize yourself with the Globus Connect Server v5 Data Access Guide, which provides detailed steps on creating and updating a storage gateway. The commands for creating and updating a storage gateway for the Google Drive Connector are similar to those in the POSIX connector example.
The GoogleDriveStoragePolicies Document outlines the connector-specific storage gateway policies for the Google Drive connector. It supports one of two schemas: GoogleDriveStoragePolicies_1_0_0 or GoogleDriveStoragePolicies_1_1_0.
Delete
Deleting files is a crucial aspect of storage management, and Google Drive provides a straightforward way to do so. You can delete a file by passing its ID as input, and Tulip will take care of the rest.
To delete a file, you'll need to provide the file ID, which is a unique identifier for the file. This ID can be obtained from the file's properties or by using the API. Once you have the ID, you can pass it as input, and the file will be deleted permanently.
Here are the key parameters you'll need to provide for deleting a file:
- File ID: This is the unique identifier for the file you want to delete.
- Configuration: This is the name of the configuration to use for the deletion operation.
- Supports All Drives: This parameter indicates whether the requesting application supports both My Drives and shared drives.
Note that deleting a file permanently removes it from the drive and cannot be recovered. If you're looking to move a file to the trash instead, you'll need to use a different operation.
Deleting permissions for a file is also an essential aspect of storage management. You can delete a permission by passing the file ID and permission ID as input. This operation makes an HTTP DELETE request to the /files/{fileId}/permissions/{permissionId} endpoint.
Here's a summary of the key parameters for deleting a permission:
Remember to provide the correct file ID and permission ID for the operation to succeed.
Patch Revisions
Patch revisions are an essential part of maintaining a healthy storage system. To list a file's revisions, you'll need to make an HTTP GET request to the /files/{fileId}/revisions endpoint.
The configuration name is required, and it's specified in the configuration field. The file ID is also required, and it's specified in the file ID field. You can also specify a page size to limit the number of revisions returned per page.
The pretty print field can be used to return the response with indentations and line breaks. The quota user field represents a user for quota purposes and must not exceed 40 characters.
Custom query parameters can be added to the request, and custom headers can also be included. The response timeout can be set to control the time it takes for the request to complete.
Authentication and Permissions
The Google Drive Connector supports two methods for authentication and authorization: based on short-lived JWT bearer token, and based on refresh token.
You can obtain both through Google's official OAuth documentation or by referring to the examples below. To enable Google Docs API and Google Drive API for every client intended to use, go to the Google Cloud API Library page.
To authenticate your Connector, you can use either method mentioned above. The Google Drive Connector also supports multiple ways to obtain a short-lived JWT bearer token and refresh token.
User Credential Policies
User Credential Policies are crucial for accessing mapped collections on Google Drive. They require users to register credentials through an authentication flow with Google, initiated by visiting the Credentials tab of the collection.
To create these credentials, users must match their Google account with their Globus identity, unless the storage-gateway --google-allow-any-account command-line option is set. This means users need to have a Google account that matches their Globus identity to access the collection.
The Google Drive Connector has policies to manage application credentials and set the user API rate quota. This helps ensure that users can access the collection without any issues.
The GoogleDriveUserCredentialPolicies Document outlines connector-specific user credential policies for the Google Drive connector. This document provides more information on the policies that govern user credentials for Google Drive.
How to Authenticate
To authenticate with the Google Drive Connector, you need to obtain credentials through Google OAuth. You can do this by referring to the official Google OAuth documentation or using the methods provided in the examples below.
There are two methods for authentication and authorization: short-lived JWT bearer token and refresh token. You can obtain both through various means, but the official documentation is the best place to start.
To enable Google Drive API and Google Docs API for your client, head to the Google Cloud API Library page. This is a crucial step, as it allows your client to access data on collections created with the Google Drive Connector type.
You can configure the client credentials using the command-line options --google-client-id and --google-client-secret. This is required to access data on collections created with the Google Drive Connector type.
To initiate the authentication flow, users need to register credentials by performing an authentication flow with Google. This is done by visiting the Credentials tab of the collection, which will direct them to the Google authentication page.
Here are the steps to configure client credentials for a tenant configuration:
- Sign in to the CMC.
- In the Navigation bar, select Clusters.
- In the cluster list, select a Cluster name.
- In the canvas tabs, select Tenant.
- For the given tenant, select Configure.
- In the left pane, select Integration.
- In the right pane, specify:
- Your Client ID in Google Drive Client ID.
- Your Client Secret in Google Drive Client Secret.
- Select Save.
After configuration, you need to restart the Analytics Service, Loader Service, and any add-ons such as the Notebook Service.
Permissions
Permissions are a crucial aspect of authentication and access control in Google Drive. A permission is created for a file or shared drive by making an HTTP POST request to the /files/{fileId}/permissions endpoint.
The configuration name is required to use a specific configuration for the operation. This is a string value that must be provided.
To create a permission, you need to specify the file ID, which is a string value that represents the ID of the file or shared drive. The supportsAllDrives parameter is also required, which is a boolean value that indicates whether the requesting application supports both My Drives and shared drives.
Other parameters that can be used when creating a permission include sendNotificationEmail, enforceSingleParent, emailMessage, prettyPrint, quotaUser, transferOwnership, key, userIp, oauthToken, and useDomainAdminAccess. These parameters can be used to customize the permission creation process.
Here are some key parameters for creating a permission:
The file ID is a required parameter when creating a permission, and it must be provided as a string value. The supportsAllDrives parameter is also required, and it must be provided as a boolean value.
To delete a permission, you need to make an HTTP DELETE request to the /files/{fileId}/permissions/{permissionId} endpoint. The file ID and permission ID are both required parameters, and they must be provided as string values.
The supportsAllDrives parameter is also required when deleting a permission, and it must be provided as a boolean value. Other parameters that can be used when deleting a permission include prettyPrint, quotaUser, key, userIp, oauthToken, and useDomainAdminAccess.
Get Team
Getting Team Drives can be a bit tricky, but don't worry, I've got you covered. To get started, you'll need an API key, which is a string that identifies your project and provides you with API access, quota, and reports.
The API key is required unless you provide an OAuth 2.0 token. If you're using an OAuth 2.0 token, you can skip the API key altogether. This is a common practice in many applications.
You can also use the quotaUser parameter to specify an opaque string that represents a user for quota purposes. This string must not exceed 40 characters.
The useDomainAdminAccess parameter is another important one. If set to true, the requester is granted access if they are an administrator of the domain to which the Team Drive belongs.
Here's a quick rundown of the parameters you can use to get Team Drives:
Now that you know the parameters, you can start building your application. Remember to always use the quotaUser parameter to specify the user for quota purposes, and set the useDomainAdminAccess parameter to true if the requester is an administrator of the domain.
API Operations
The Google Drive connector offers a range of API operations to interact with Google Drive. These operations can be categorized into file and folder listings, file downloads, file uploads, file updates, and file deletions.
You can use the files.list and files.get API calls to retrieve file and folder listings, with multiple calls per listing request depending on the path length. Results are cached within a given session.
Here's a breakdown of the API calls:
These API operations can be used to perform various tasks, such as downloading files, creating new files and folders, and updating existing files and folders.
API Setup
API Setup can be a daunting task, but don't worry, I've got you covered. Setting up Google API is the hardest part of integrating, so let's break it down step by step.
The first step is to create a Google API Project, which can be a bit tricky. Check out the video guide for a walkthrough on how to do it.
To specify the client credentials for the Default Tenant Configuration, you'll need to sign in to the CMC and navigate to the Cluster Configurations panel. From there, select the Integration tab and fill in your Google Drive Client ID and Client Secret.
Here's a step-by-step guide to specifying the client credentials:
- Sign in to the CMC.
- In the Navigation bar, select Clusters.
- In the cluster list, select a Cluster name.
- In the canvas tabs, select Cluster Configurations.
- In the panel tabs, select Default Tenant Configurations.
- In the left pane, select Integration.
- In the right pane, specify your Client ID in Google Drive Client ID.
- In the right pane, specify your Client Secret in Google Drive Client Secret.
- Select Save.
API Calls
API calls are the backbone of any API operation, and understanding how they work is crucial for successful interactions. The Google Drive API, for instance, uses various API calls to manage files and folders.
The Google Drive API uses the following API calls to manage files and folders: files.list, files.get, files.create, files.update, files.delete, and files.copy. Each of these API calls serves a specific purpose, such as listing files, downloading a file, creating a new file or folder, updating file metadata, deleting a file or folder, or copying a file.
Here's a breakdown of the frequency of each API call:
- files.list and files.get: Multiple calls per listing request, depending on path length
- files.get: Per file
- files.create: Per file
- files.update: Per file
- files.delete: Per file
- files.copy: Per stub upload
The Google Drive API also uses other API calls, such as drives.list and drives.create, to manage shared drives.
Here's a list of API calls used by the Google Drive Connector:
- files.create: Creates a new file or folder
- files.list: Lists files and folders
- files.get: Downloads a file
- files.update: Updates file metadata
- files.delete: Deletes a file or folder
- drives.list: Lists shared drives
- drives.create: Creates a new shared drive
These API calls are essential for interacting with the Google Drive API and are used in various operations, such as getting file metadata, listing files, and creating new files and folders.
Folder and Template Management
To create a new folder in Google Drive, you'll need to set the required credentials in the Authentication section and select the "Create Folder" operation type. This is a straightforward process that requires just a few clicks.
You can also specify a parent folder ID to create the new folder inside an existing folder. If you don't specify a parent folder ID, the new folder will be created in the root folder of the user who owns the OAuth token.
In the Operation Details section, you can also add additional properties or metadata to the new folder, such as a description. This requires using FEEL expressions, which are compatible with Google Drive.
Here are the basic steps to create a new folder:
To create a new file from a template, you'll follow a similar process, but with a few key differences. You'll need to select the "Create File from template" operation type and specify the template ID of the desired template.
Patch Team
Patching Team Drives requires attention to detail and the right configuration. The name of the configuration to use is a crucial piece of information, and it must be specified in the request.
To patch a Team Drive, you'll need to provide the ID of the Team Drive, which is a unique identifier assigned to the Team Drive. This ID must be included in the request.
The pretty print option can be used to return the response with indentations and line breaks, making it easier to read. However, this option is not required.
Patching a Team Drive also requires an API key, which identifies your project and provides you with API access, quota, and reports. This API key is a required parameter unless you provide an OAuth 2.0 token.
Here are the required parameters for patching a Team Drive:
These parameters must be included in the request to successfully patch a Team Drive.
New Folder
To create a new folder, you'll need to set the required credentials in the Authentication section, which you can find more about in the relevant appendix entry.
The first step is to set the field value Operation Type as Create Folder in the Select Operation section. This is a straightforward process that gets you started on creating a new folder.
You can set the field Folder name as the desired name of a folder you wish to create, such as MyNewFolder. Alternatively, you could use a FEEL expression.
If you want to create the folder inside a specific parent folder, you can set the field Parent folder ID to the desired parent in the Operation Details section. Otherwise, the new folder will be created in the Google Drive root folder of the user who owns the OAuth token.
You can also add additional properties or metadata to the folder by setting the Additional properties or metadata field in the Operation Details section. This field requires FEEL input, which you can find more about in the appendix.
Here's a summary of the steps to create a new folder:
- Set the required credentials in the Authentication section.
- Set the field value Operation Type as Create Folder in the Select Operation section.
- Set the field Folder name as the desired name of the folder you wish to create.
- (Optional) Set the field Parent folder ID to the desired parent folder.
- (Optional) Set the Additional properties or metadata field to add extra details to the folder.
The Google Drive Connector uses the Google Drive Files:Create API endpoint to create a new folder, which is a powerful tool for managing your folders and templates.
Creating from a Template
Creating from a template is a fantastic way to quickly set up a new file with a pre-defined structure. To create a new file from a template, you'll need to set the required credentials in the Authentication section.
You can do this by referring to the relevant appendix entry to find out more. In the Select Operation section, set the field value Operation Type as Create File from template.
To specify the file name, you'll need to set the field File name in the Operation Details section. You can use FEEL expressions here, which allows for dynamic naming based on user input or other variables.
The Template ID of the desired template should also be set in the Operation Details section. This tells the system which template to use as the basis for the new file.
If you want to create the new file inside a specific parent folder, you can set the field Parent folder ID in the Operation Details section. If not specified, a new folder will be created in the Google Drive root folder of the user who owns the OAuth token.
You can also set the Template variables in the Operation Details section, which allows you to customize the template with specific values. The template variables are compatible with the Google Docs Requests API and require FEEL input.
Here's a table summarizing the required fields for creating a new file from a template:
Currently, the Google Drive Connector supports only Google Doc files (MIME type application/vnd.google-apps.document) as templates.
Template Location
To find a Google Docs template, you'll need to locate the Template ID. This can be done by opening the link to the Google Docs template in your web browser.
The URL will look something like this: https://docs.google.com/document/d/1whNL0a6WjZtYRHF2522FrCYUYxHve9ju-DHNkaTm9Sk.
The Template ID is the alphanumeric string after /d/.
Frequently Asked Questions
What is Google Connector?
A Google Connector is a custom program that allows you to index data from a third-party repository in Google Cloud Search. This enables you to extend the search capabilities of Google Cloud Search to include data from external sources.
Sources
- https://docs.globus.org/premium-storage-connectors/v5.4/google-drive/
- https://support.tulip.co/docs/google-drive-connector
- https://docs.camunda.io/docs/components/connectors/out-of-the-box-connectors/googledrive/
- https://docs.mulesoft.com/google-drive-connector/latest/google-drive-connector-reference
- https://docs.incorta.com/6.0/references-connectors-google-drive
Featured Images: pexels.com