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
Enter your project name and click "Create"
If necessary, add an 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
IMPORTANT: Save the
.json
fileOpen APIs and services > OAuth consent screen
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.)
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)
Use string from "private_key" field as Private key
IMPORTANT: Need to replace all "\n" symbols in key with linebreak ("Enter" button)!
Plugin elements
Drive Uploader
Special File Loader for Base64 Returning Files
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
- 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
- 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
- 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
- file - The file to be uploaded
Create a File
Create a file or folder on Google Drive
- 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.
- /fileId - The ID of the file.
Give Everyone Permission (Read)
Gives everyone permission to read file on Google Drive
- /fileId - The ID of the file.
Remove Everyone With Link Permission
Deletes a permission to access with link.
- /fileId - The ID of the file.
Remove Permission Using ID
Remove permission from file using file id and permission id.
- /fileId - The ID of the file
- /permissionIdThe ID of the permission
Give a User Permission (Write)
Give a user write permission.
- /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
- /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.
- /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.
- /fileId - The ID of the file
- /permissionId - The ID of the permission
Delete File
Delete file from Google Drive
- /fileId - The ID of the file
Get File Info
Get information about file
- /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
- /fileId - The ID of the file
- Folder ID - The ID of the folder
Remove File From Folder
- /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.
- /fileId - The ID of the image file
Update File
Update file name
- fileId - The ID of the file
- New Name - New name of the file
Get Folder Childrens
Return childrens of folder
- 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.
- File ID - The ID of the file
- MIME Type - Mime Type of the file
Download File
Return Download URL of the file
- 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'