# Share File — Google Drive

> Share a file or folder in Google Drive by creating a sharing permission. Supports sharing with a specific user, a group, an entire domain, or anyone with the link. Use Search Files first to find the file ID by name.

- Key: `google_drive-share-file`
- Type: Action (Write)
- Version: 0.0.4
- App: Google Drive (`google_drive`) — https://pipedream.com/apps/google-drive.md
- This page (HTML): https://pipedream.com/apps/google-drive/actions/share-file
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/google_drive/actions/share-file/share-file.mjs

## Description

Share a file or folder in Google Drive by creating a sharing permission. Supports sharing with a specific user, a group, an entire domain, or anyone with the link. Use **Search Files** first to find the file ID by name.

**Sharing types:**
- `user` — share with a specific person (requires `emailAddress`)
- `group` — share with a Google Group (requires `emailAddress`)
- `domain` — share with everyone in a Google Workspace domain (requires `domain`)
- `anyone` — share with anyone who has the link (no email/domain needed)

**Roles:** `reader` (view only), `commenter` (can comment), `writer` (can edit). Use **List Permissions** to see existing sharing on a file. [See the documentation](https://developers.google.com/drive/api/v3/reference/permissions/create)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `fileId` | `string` | Yes | The ID of the file or folder to share. Use Search Files to find the file ID by name. |
| `type` | `string` | Yes | The type of grantee: user, group, domain, or anyone. |
| `role` | `string` | Yes | The access level to grant: reader (view), commenter (comment), or writer (edit). |
| `emailAddress` | `string` | No | The email address of the user or group to share with. Required when type is user or group. Ignored for domain and anyone. |
| `domain` | `string` | No | The Google Workspace domain to share with (e.g., example.com). Required when type is domain. Ignored for other types. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "google_drive",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "google_drive-share-file",
  arguments: {
    fileId: "File ID",
    type: "Type",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "google_drive-share-file",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    google_drive: { authProvisionId: "apn_xxxxxxx" },
    fileId: "File ID",
    type: "Type",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "google_drive-share-file",
    "configured_props": {
      "google_drive": { "authProvisionId": "apn_xxxxxxx" },
      "fileId": "File ID",
      "type": "Type"
    }
  }'
```

---

- App: https://pipedream.com/apps/google-drive.md · All apps: https://pipedream.com/apps
