Google Drive (Service Acc.) Plugin

Demo to preview the settings

Introduction

Push files to Google Drive using a Service Account both as Base64 or File Type. The easiest way to allow your app to move data on its own.
NOTE: This is the JSON WEB Token authentication version, users will access the Service Account Google Drive. For the information on how to obtain Service Account Keys for a Service Acc. Plugin, please read here: https://docs.zeroqode.com/obtaining-google-service-account-keys
All pushed files are stored in Google Service account and can be retrieved only through the API (for instance- Get Files). The files are NOT stored in Google Drive itself.
💡
TIP: Service accounts, types of service accounts, and the IAM roles that are available to service accounts please find here: https://cloud.google.com/iam/docs/service-accounts
A shared drive is an organizational structure within Google Drive that lives parallel to My Drive. You can organize an individual file within a shared drive or in My Drive but not both. For more details please visit this page: https://developers.google.com/drive/api/v3/about-files

Prerequisites

For using the plugin you'll need to get the API credentials with JWT for Google Create your development account at: https://console.cloud.google.com/home/dashboard and also enable Google Drive API in the console.

How to setup

Go to your Google Console and add a new project.
Image without caption
Image without caption
Enter your project name and click "Create"
If necessary, add an organization
Image without caption
Select your project
Image without caption
Image without caption
Go to APIs and services > Library
Image without caption
Find Google Drive API and click it
Image without caption
Press Enable
Image without caption
Go to APIs and services > Credentials
Image without caption
Click Create Credentials
Image without caption
In appeared dropdown select Service account
Image without caption
Enter service account name
Image without caption
You can skip the next two steps
Image without caption
Click Service Account email
Image without caption
Select KEYS tab
Image without caption
Add key
Image without caption
Image without caption
Image without caption
IMPORTANT: Save the .json file
Open APIs and services > OAuth consent screen
Image without caption
Select as user type External and press Create and complete form
Image without caption
Find your .json file and open it
You can open file with any text editor (Notepad, Notepad++, Sublime Text, Atom, etc.)
Image without caption
Image without caption
javascript
{ "type": "service_account", "project_id": "project-id", "private_key_id": "key-id", "private_key": "-----BEGIN PRIVATE KEY-----\nprivate-key\n-----END PRIVATE KEY-----\n", "client_email": "service-account-email", "client_id": "client-id", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://accounts.google.com/o/oauth2/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account-email" }
Use string from "client_email" as Iss (account email)
Image without caption
Image without caption
Use string from "private_key" field as Private key
IMPORTANT: Need to replace all "\n" symbols in key with linebreak ("Enter" button)!
Image without caption

Plugin elements

Drive Uploader

Special File Loader for Base64 Returning Files
Image without caption
Fields
  • Content - The content displayed in the uploader
  • Borders - Enable borders
  • Borders Width(px) - Borders width
  • Border Color - Borders Color
  • Border Radius(px) - Borders radius
  • Background Color - Background color of uploader
Exposed States
  • files - Uploaded file encoded in base64 (Text)info - Mime Type of the file uploaded file (Text)Name - Name of the uploaded file (Text)
Actions
  • Reset - Reset uploader data.
Events
  • Click - This event is triggered when the uploader is clicked.

Plugin actions

Generate Sort Query

Generates a special search line to send in the Search/Get Files request
Image without caption
Image without caption
Image without caption
Image without caption
Image without caption
  • Operator - Enum. Each field has its own possible operators.
  • Operator (Dynamic) - Value from the dropdown but passed dynamically for more flexible settings
  • Value - Value of the field
Once generated, you must pass the value of the return action to api call.
Image without caption

Plugin API Calls

Search/Get Files

Returns files from Google Drive
Image without caption
  • hash (Text or Number) - In order not to send identical requests, hash is used. Use Current date/time for this field
  • q (Text) - To search for a specific set of files or folders, use the query string. Google Docs
To generate a correct query string you can use the Generate Sort Query action​

Upload a File (base64)

Upload a file to Google Drive
Image without caption
  • file mime type - MimeType of the uploaded file
  • file as base64 - base64 encoded file
  • file_name - name of file
  • mime_type - MimeType of the uploaded file
  • file_description - Description of the file​

Upload a File

Upload binary file to Google Drive
Image without caption
  • file - The file to be uploaded​

Create a File

Create a file or folder on Google Drive
Image without caption
  • mime_type - MimeType of creating file
  • folder_name - Folder name
  • file_description - File description​

Give Everyone Permission (Write)

Gives everyone permission to change or to create file to Google Drive.
Image without caption
  • /fileId - The ID of the file.​

Give Everyone Permission (Read)

Gives everyone permission to read file on Google Drive
Image without caption
  • /fileId - The ID of the file.​

Remove Everyone With Link Permission

Deletes a permission to access with link.
Image without caption
  • /fileId - The ID of the file.​

Remove Permission Using ID

Remove permission from file using file id and permission id.
Image without caption
  • /fileId - The ID of the file
  • /permissionIdThe ID of the permission​

Give a User Permission (Write)

Give a user write permission.
Image without caption
  • /fileId - The ID of the file
  • emailAddress - Email address to give access to
  • sendNotification - Send notification to user email. If is blank email will not be sent
  • emailMessage - Custom message in email

Give a User Permission (Read)

Give a user read permission
Image without caption
  • /fileId - The ID of the file
  • emailAddress - Email address to give access to
  • sendNotification - Send notification to user email. If is blank email will not be sent
  • emailMessage - Custom message in email​

Update a User's Permission (Write)

Give to user permission and set its role to the writer.
Image without caption
  • /fileId - The ID of the file
  • /permissionId - The ID of the permission​

Update a User's Permission (Read)

Give to user permission and set its role to the reader.
Image without caption
  • /fileId - The ID of the file
  • /permissionId - The ID of the permission​

Delete File

Delete file from Google Drive
Image without caption
  • /fileId - The ID of the file​

Get File Info

Get information about file
Image without caption
  • /fileId - The ID of the file
  • hash - In order not to send identical requests, hash is used. Use Current date/time for this field​

Add File to Folder

Image without caption
  • /fileId - The ID of the file
  • Folder ID - The ID of the folder​

Remove File From Folder

Image without caption
  • /fileId - The ID of the file
  • /folderID - The ID of the folder
  • parent id - The ID of the folder​

Get Image from Drive

Returns image from Google Drive as media.
Image without caption
  • /fileId - The ID of the image file​

Update File

Update file name
Image without caption
  • fileId - The ID of the file
  • New Name - New name of the file​

Get Folder Childrens

Return childrens of folder
Image without caption
  • Folder ID - The ID of the folder
  • hash - In order not to send identical requests, hash is used. Use Current date/time for this field​

Export File

Exports a Google Doc to the requested MIME type and returns the exported content. Please note that the exported content is limited to 10MB.
Image without caption
  • File ID - The ID of the file
  • MIME Type - Mime Type of the file​

Download File

Return Download URL of the file
Image without caption
  • File ID - The ID of the file​​

Get Files (API v3) Extended

Advanced API call setup, returns all disk files including files nested in folders
Image without caption
  • hash (Text or Number) - In order not to send identical requests, hash is used. Use Current date/time for this field
  • supportsAllDrives - Whether the requesting application supports both My Drives and shared drives.
  • corpora - Bodies of items (files/documents) to which the query applies. Supported bodies are 'user', 'domain', 'drive', and 'allDrives'. Prefer 'user' or 'drive' to 'allDrives' for efficiency. By default, corpora is set to 'user'.
  • driveId - ID of the shared drive to search.
  • includeItemsFromAllDrives - Whether both My Drive and shared drive items should be included in results.
  • trashed - Use the "false" to remove trashed files from the results
  • orderBy - A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but can be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name.
  • pageSize - The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached.
  • pageToken - The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
  • spaces - A comma-separated list of spaces to query within the corpora. Supported values are 'drive' and 'appDataFolder'.
  • includeLabels - A comma-separated list of IDs of labels to include in the labelInfo part of the response.
  • includePermissionsForView - Specifies which additional view's permissions to include in the response. Only 'published' is supported.

Get Files (API v3) Extended

Returns list of files and folders inside folder or drive
Image without caption
  • Folder ID - The ID of the folder or shared drive
  • hash - In order not to send identical requests, hash is used. Use Current date/time for this field
  • trashed - Use the "false" to remove trashed files from the results

Things to Note

For file name untitled issue , you'll need to create a workflow of a few steps, both of which are calls found in plugin:
  • Upload File -> (Get File Id result from step 1) -> Rename File.

Changelogs

Update 30.04.2021

  • Added new element 'Drive Uploader'

Update 27.09.2021

Improvement: Version: 1.9.0
  • Retrieving and searching files has been reworked. Added an action to generate a search query.

Update 27.09.2021

Improvement: Version: 1.9.0
  • Retrieving and searching files has been reworked. Added an action to generate a search query.

Update 18.11.21

Improvement: Version: 1.10.0
  • Added support for multiple uploaders per page

Update 02.03.2022

Improvement: 1.11.0
  • Fixed event 'click' and renamed to 'File uploaded'

Update 14.11.23

Fix: 1.21.0
  • Fixed parameters in Api call "Get File Info"

Update 20.11.23

Improvement: 1.22.0
  • Added API calls "Get list of files inside folder or drive(API v3)" and "Get Files (API v3) Extended"

Update 23.11.23

Improvement: 1.23.0
  • Added parameter "q" for API call "Get Files (API v3) Extended"