Google Drive — Share
Google Drive — Share
Section titled “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.
How it works
Section titled “How it works”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 = userorgroup: shares with a person or a Google group;emailis required.type = anyone: anyone with the link (noemailneeded). The link is the file’swebViewLink.type = domain: shares with every account in a Google Workspace domain;domainis 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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | File or folder ID. |
role | string | — | Permission level: reader, commenter or writer. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanGoogleDriveSession | — | Session from Google Drive — Connect. Inside Connect’s body it is inherited and you can leave it empty. |
type | string | user | Who gets it: user, group, domain or anyone. |
email | string | — | Email of the user or group. Required with type user or group. |
domain | string | — | Domain that receives the permission, e.g. example.com. Required with type domain. Since version 1.0.5. |
notify | bool | true | Send Google’s notification email to the recipient (user/group). |
Output
Section titled “Output”Returns a Dictionary with the created permission:
| Key | Type | Content |
|---|---|---|
permissionId | string | Permission ID (Google uses anyoneWithLink for the link permission). |
role | string | Level granted: reader, commenter or writer. |
type | string | Recipient type: user, group, domain or anyone. |
email | string | Recipient email; null with domain and anyone. |
domain | string | Permission domain with type domain; null otherwise. |
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”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"]Related activities
Section titled “Related activities”- Google Drive — Upload — upload the file to share.
- Google Drive — Get info — get the file link.
- Google Drive — Create folder — share a whole folder.
- All Google Drive activities