84min

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.

Document image
Document image



Enter your project name and click "Create"

If necessary, add an organization

Document image



Select your project

Document image
Document image



Go to APIs and services > Library

Document image



Find Google Drive API and click it

Document image



Press Enable

Document image



Go to APIs and services > Credentials

Document image



Click Create Credentials

Document image



In appeared dropdown select Service account

Document image



Enter service account name

Document image



You can skip the next two steps

Document image



Click Service Account email

Document image



Select KEYS tab

Document image



Add key

Document image
Document image
Document image

Save the .json file

Open APIs and services > OAuth consent screen

Document image



Select as user type External and press Create and complete form

Document image



Find your .json file and open it

You can open file with any text editor (Notepad, Notepad++, Sublime Text, Atom, etc.)

Document image
Document image
JS
|

Use string from "client_email" as Iss (account email)

Document image
Document image

Use string from "private_key" field as Private key

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

Document image

Plugin elements

Drive Uploader

Special File Loader for Base64 Returning Files

Document image



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

Document image
Document image
Document image
Document image
Document image
  • 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.

Document image

Plugin API Calls

Search/Get Files

Returns files from Google Drive

Document image
  • 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

Document image



  • 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

Document image



  • file - The file to be uploaded​

Create a File

Create a file or folder on Google Drive

Document image



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

Document image



  • /fileId - The ID of the file.​

Give Everyone Permission (Read)

Gives everyone permission to read file on Google Drive

Document image



  • /fileId - The ID of the file.​

Deletes a permission to access with link.

Document image



  • /fileId - The ID of the file.​

Remove Permission Using ID

Remove permission from file using file id and permission id.

Document image



  • /fileId - The ID of the file
  • /permissionIdThe ID of the permission​

Give a User Permission (Write)

Give a user write permission.

Document image



  • /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

Document image



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

Document image



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

Document image



  • /fileId - The ID of the file
  • /permissionId - The ID of the permission​

Delete File

Delete file from Google Drive

Document image



  • /fileId - The ID of the file​

Get File Info

Get information about file

Document image



  • /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

Document image



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

Remove File From Folder

Document image



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

Document image



  • /fileId - The ID of the image file​

Update File

Update file name

Document image



  • fileId - The ID of the file
  • New Name - New name of the file​

Get Folder Childrens

Return childrens of folder

Document image



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

Document image



  • File ID - The ID of the file
  • MIME Type - Mime Type of the file​

Download File

Return Download URL of the file

Document image



  • 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

Update 02.03.2022

Improvement: 1.11.0

  • Fixed event 'click' and renamed to 'File uploaded'

Demo to preview the settings