Plugins
Templates
Google Drive (Service Acc.) Plugin

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.
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.

Enter your project name and click "Create"

If is necessary add organization

Select your project

Go to APIs and services > Library

Find Google Drive API and click it

Press Enable

Go to APIs and services > Credentials

Click Create Credentials

In appeared dropdown select Service account

Enter service account name

You can skip the next two steps

Click Service Account email

Select KEYS tab

Add key

Save .json file

Select as user type External and press Create and complete form

Find your .json file and open it

You can open file with any text editor (Notepad, Notepad++, Sublime Text, Atom, etc.)
Example of file
1
{
2
"type": "service_account",
3
"project_id": "project-id",
4
"private_key_id": "key-id",
5
"private_key": "-----BEGIN PRIVATE KEY-----\nprivate-key\n-----END PRIVATE KEY-----\n",
6
"client_email": "service-account-email",
7
"client_id": "client-id",
8
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
"token_uri": "https://accounts.google.com/o/oauth2/token",
10
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account-email"
12
}
Copied!
Use string from "client_email" as Iss (account email)

Use string from "private_key" field as Private key

Need to replace all "\n" symbols in key with linebreak ("Enter" button)

Plugin elements

Drive Uploader

Special File Loader for Base64 Returning Files
Fields
Exposed States
Actions
Events
Title
Description
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
Title
Description
Type
files
Uploaded file encoded in base64
Text
info
Mime Type of the file uploaded file
Text
Name
Name of the uploaded file
Text

Reset

Reset uploader data.

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
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.

Plugin API Calls

Search/Get Files

Returns files from Google Drive
Title
Type
Description
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
Title
Description
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
Title
Description
file
The file to be uploaded

Create a File

Create a file or folder on Google Drive
Title
Description
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.
Title
Description
/fileId
The ID of the file.

Give Everyone Permission (Read)

Gives everyone permission to read file on Google Drive
Title
Description
/fileId
The ID of the file.
Deletes a permission to access with link.
Title
Description
/fileId
The ID of the file.

Remove Permission Using ID

Remove permission from file using file id and permission id.
Title
Description
/fileId
The ID of the file
/permissionId
The ID of the permission

Give a User Permission (Write)

Give a user write permission.
Title
Description
/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
Title
Description
/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.
Title
Description
/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.
Title
Description
/fileId
The ID of the file
/permissionId
The ID of the permission

Delete File

Delete file from Google Drive
Title
Description
/fileId
The ID of the file

Get File Info

Get information about file
Title
Description
/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

Title
Description
/fileId
The ID of the file
Folder ID
The ID of the folder

Remove File From Folder

Title
Description
/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.
Title
Description
/fileId
The ID of the image file

Update File

Update file name
Title
Description
fileId
The ID of the file
New Name
New name of the file

Get Folder Childrens

Return childrens of folder
Title
Description
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.
Title
Description
File ID
The ID of the file
MIME Type
Mime Type of the file

Download File

Return Download URL of the file
Title
Description
File ID
The ID of the file

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

Demo to preview the settings

Last modified 2mo ago