Skip to main content
Technical Preview

Overview

A client-mode connector for a curated slice of Google Drive API v3 under https://www.googleapis.com: Default BASE_ADDRESS is https://www.googleapis.com (no trailing slash). Metadata endpoints start with /drive/v3/; media uploads use /upload/drive/v3/. Topics use storage/google-drive/<object>/<verb>. See the base guide: REST API Connectors.
Search queries: put the Drive query in {value.json.q} already URL-encoded. Example: name contains 'line-a' and trashed=false → name%20contains%20%27line-a%27%20and%20trashed%3Dfalse. Send "q": "" to list everything visible to the token.
Shared drives: every event sends supportsAllDrives=true and the list event also sends includeItemsFromAllDrives=true, so files in shared drives work without extra flags.
Prefer Hub secrets for access tokens (GET SECRET "GOOGLE_DRIVE_TOKEN" or "GOOGLE_ACCESS_TOKEN"). Scope: https://www.googleapis.com/auth/drive.file (least privilege, files the app created or opened) or https://www.googleapis.com/auth/drive (full). This template has not been verified against a live Google Cloud project. Status remains blocked until an authenticated live smoke succeeds.

Basic Syntax

Auth

  1. Enable Google Drive API on a Google Cloud project.
  2. Obtain an OAuth 2.0 user access token or a service-account access token. A service account has its own Drive: share the target folder (or shared drive) with the service-account email, or use domain-wide delegation in Google Workspace.
  3. Scope: https://www.googleapis.com/auth/drive.file covers files the connector creates. Use https://www.googleapis.com/auth/drive to read or update files created elsewhere. Use .../drive.metadata.readonly only if you stick to GET events.
  4. Pass api_token on each MQTT payload → Authorization: Bearer {value.json.api_token}. Prefer Hub secrets / GET SECRET "GOOGLE_DRIVE_TOKEN" or "GOOGLE_ACCESS_TOKEN". Never commit real tokens.
Access tokens expire after about one hour. Refresh them outside the connector (service-account JWT exchange or OAuth refresh token) and update the secret.

MQTT topics

Example payloads

Credential smoke (GetAbout):
Search a line folder (ListFiles):
Body fields: CreateFile, UpdateFile, and UploadFileMedia send {payload} as the body. Google APIs can reject unknown JSON fields (such as api_token or fileId) with HTTP 400. If your broker forwards the whole payload, publish only Drive file fields and inject the Bearer from a Hub secret or connector wiring.
Create a per-device folder (CreateFile):
Rename and tag a report (UpdateFile):
Move to trash (recoverable — prefer this over DeleteFile):
Delete permanently (DeleteFile → HTTP 204):

Uploads (advanced)

UploadFileMedia uses uploadType=media: the whole MQTT payload becomes the file content (application/json, up to 5 MB). Drive names the file Untitled with no parent, so follow with UpdateFile using the returned id to set name and move it with addParents.
With uploadType=media, everything in {payload} is stored in the file. Do not put api_token in the payload for this event in production. Inject the Bearer from a Hub secret or connector wiring instead, or the token ends up inside the uploaded file.
uploadType=multipart (metadata and content in one multipart/related request) and uploadType=resumable (large files) are not templated. They need a multipart body or a two-step session that a single MQTT JSON payload does not map to cleanly.

Push notifications

Drive can push change notifications (files.watch, changes.watch) to an HTTPS webhook. That is a server-mode companion (ENABLE_SERVER) and is not part of this client template.

Quotas and limits

Google Drive API enforces per-project and per-user quotas. Bursts from many devices can return HTTP 403 userRateLimitExceeded or 429. Batch snapshots at the edge and back off on errors.

Deploy notes

  • Deploy only GoogleDriveRestApi.lot with -addRoute / Hub deploy. Do not deploy hub-metadata.lot.
  • Hub listing uses hub-metadata.lot (WITH IMAGE, WITH STATUS "beta", doclink).
  • Suggested branches (Hugo pushes): feat/rest-api-route-google-drive, feat/docs-rest-api-google-drive.
Last modified on October 21, 2026