Skip to content

Google Drive — Share

Type: googledrive-share  ·  Package: Google Drive v1.0.5  ·  Output: Dictionary<string,object>

Shares a file or folder by granting a permission. Set who gets access (type) and at what level (role): reader, commenter or writer. That way the robot delivers a document to a customer or opens a folder to a team with no manual steps.

Creates a new permission on the item id; the permissions it already had are kept. Sharing a folder gives access to all its content.

  • type = user or group: shares with a person or a Google group; email is required.
  • type = anyone: anyone with the link (no email needed). The link is the file’s webViewLink.
  • type = domain: shares with every account in a Google Workspace domain; domain is required (e.g. example.com). Since version 1.0.5.

notify sends Google’s notification email to the person or group. It only applies to user and group; with domain and anyone no notification is sent.

ParameterTypeDefaultDescription
idstring—File or folder ID.
rolestring—Permission level: reader, commenter or writer.
ParameterTypeDefaultDescription
sessionZoanGoogleDriveSession—Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty.
typestringuserWho gets it: user, group, domain or anyone.
emailstring—Email of the user or group. Required with type user or group.
domainstring—Domain that receives the permission, e.g. example.com. Required with type domain. Since version 1.0.5.
notifybooltrueSend Google’s notification email to the recipient (user/group).

Returns a Dictionary with the created permission:

KeyTypeContent
permissionIdstringPermission ID (Google uses anyoneWithLink for the link permission).
rolestringLevel granted: reader, commenter or writer.
typestringRecipient type: user, group, domain or anyone.
emailstringRecipient email; null with domain and anyone.
domainstringPermission domain with type domain; null otherwise.
MessageCause and fix
'id' is required.id is empty or its expression returned null.
'email' is required when type is 'user' or 'group'.The recipient’s email is missing.
'domain' is required when type is 'domain' (e.g. example.com).With type domain, set the domain in domain.
No Google Drive session available. Provide 'session' from a googledrive-connect activity, or place this activity inside the Connect activity's body …The activity is outside Connect’s body and received no session. Move it inside the body or pass the saved session.
The service drive has thrown an exception. HttpStatusCode is BadRequest…Email unknown to Google, a domain that is not a Google Workspace domain, or a Workspace policy prevents sharing outside the organization.
The service drive has thrown an exception. HttpStatusCode is …Google rejected the call: unknown ID or no access, expired token or quota exceeded. See Google API errors.

Upload a report and share it with a customer as reader, notifying them by email:

Google Drive — Connect credential = credential("drive-operations")
└─ body:
Google Drive — Upload path = reportPath folderId = deliveriesId → output: uploaded
Google Drive — Share id = uploaded["id"] type = user email = customerEmail role = reader → output: permission
Log message = "Shared with " + permission["email"] + ": " + uploaded["webViewLink"]