# Google Drive

Upload, download, move, share and search files in Google Drive.

## Connect Google Drive

1. In the sidebar, open **Connections** and press **Add connection**.
2. Type `drive` and choose **Google Drive**.
3. Press **Sign in with Google**.
4. Choose your account in Google’s window and allow access.

You should see **Signed in as** and the account’s address. GoRunner can then see, edit, create and delete its Drive files.

You can also connect from a step: under **Connection**, press **New**.

**What if it says “Google sign-in isn’t set up here”?**

This installation has no Google app yet. An admin of the installation sees **Set up Google sign-in** instead, and sets it up once for everyone:

1. In Google Cloud, create an OAuth client of type **Web application**, and turn on the API for Google Drive.
2. In GoRunner, copy the **Redirect address to add in Google Cloud**, and add it to the client.
3. Paste the **Client ID** and **Client secret**, then press **Save and sign in**.

Publish the app in Google Cloud. An app left in Testing signs everyone out after 7 days.

Everyone else sees who to ask. Until it is set up, **Paste an access token instead** lets you try a step. A pasted token lasts about an hour and can’t renew itself.

[Set up Google sign-in for connections](https://docs.gorunner.io/self-host/oauth-apps)

**Can I use my own Google app?**

Yes. In the sheet, open **Use your own Google app** and paste its **Client ID** and **Client secret**. Add the **Redirect address to add in Google Cloud** to your app first. The connection then signs in through your app instead of the installation’s.

[Connections](https://docs.gorunner.io/build/connections) says how to sign in again, rename or delete it. In a product that embeds GoRunner, **Add connection** can be missing: then [your provider makes connections](https://docs.gorunner.io/embed/customer-connections) for you.

## Start a workflow

Add a trigger and choose **Google Drive**. The trigger uses the same connection as the steps.

### On File/Folder Change

Polls Drive (about once a minute) and fires for each newly created or updated file/folder in the watched location.

- **Trigger On · Optional**: Watch a whole folder, or a single specific file. Options: A folder, A specific file. Default: A folder.
- **File · Required**: The file id (or Drive URL) to watch for updates. Shows when **Trigger On** is **A specific file**.
- **Folder · Optional**: The folder id (or Drive URL) to watch. Blank = My Drive root, and only its direct children fire (with a Shared Drive set, blank watches the whole shared drive). Shows when **Trigger On** isn’t **A specific file**.
- **Watch For · Optional**: Which change starts the workflow. Options: File Created, File Updated, Folder Created, Folder Updated. Default: File Created. Shows when **Trigger On** isn’t **A specific file**.
- **Shared Drive (optional) · Optional**: Restrict to this shared drive id. Shows when **Trigger On** isn’t **A specific file**.
- **File Type (optional) · Optional**: Only fire for files of this type. Options: Any, Google Docs, Google Sheets, Google Slides, PDF, JPEG, PNG, MP4 Video. Shows when **Trigger On** isn’t **A specific file**.

A later step can use its data, such as `{{trigger.change_type}}`, `{{trigger.id}}`, `{{trigger.mimeType}}` and 3 more. See [Use data from earlier steps](https://docs.gorunner.io/build/use-data-from-earlier-steps).

## Do things in Google Drive

Add a **Google Drive** step, choose a **Resource**, then an **Operation**. Choose a row to see its fields.

- [File](https://docs.gorunner.io/apps/google-drive#fields-f-file): Upload · Download · Create From Text · Copy · Move · Share · Update · Delete
- [Folder](https://docs.gorunner.io/apps/google-drive#fields-f-folder): Create · Share · Delete
- [File/Folder (Search)](https://docs.gorunner.io/apps/google-drive#fields-f-filefolder): Search
- [Shared Drive](https://docs.gorunner.io/apps/google-drive#fields-f-drive): Create · Get · Get Many · Update · Delete

Later steps read a step’s output by its name: see [Use data from earlier steps](https://docs.gorunner.io/build/use-data-from-earlier-steps).

Not in your list? See [When an app isn’t here](https://docs.gorunner.io/apps/when-an-app-isnt-here#q-not-in-list).

## For developers

In the API, which calls apps pieces, Google Drive is `pieceId: "googledrive"` with `actionId: "googledrive"`, set by `resource` and an `operation_…` field, such as `operation_drive`. Its trigger is `googledrivetrigger` / `googledrive_poll`. [Get an app](https://docs.gorunner.io/api/apps/get-app) returns every field.

It can change something outside the run (`writes_external`). See [How versions and side effects work](https://docs.gorunner.io/apps#q-versions).

### Google Drive › File

### Upload

- **Name · Optional**: File name (blank keeps the original / a default).
- **File · Required**: A file object from a previous step (such as {{steps.x.file}}), a data URL, or base64.
- **Parent Folder · Optional**: Destination folder id (or a Drive URL). Blank = My Drive root (for Copy: keep the same folder).
- **Shared Drive · Optional**: Destination shared drive id (optional; used when no folder is given).

### Download

- **File · Required**: The file id (or a Drive URL).
- **Google File Conversion · Optional**: Export format for Google-native files (Docs/Sheets/Slides). Ignored for regular files. Options: Auto (PDF), PDF, Word (DOCX), Excel (XLSX), CSV, HTML, Plain Text, PNG.

### Create From Text

- **Name · Optional**: File name (blank keeps the original / a default).
- **Text Content · Required**: The text to write into the new file. Supports expressions.
- **Convert to Google Doc · Optional**: Import the text as a Google Doc instead of a plain text file. Off by default.
- **Parent Folder · Optional**: Destination folder id (or a Drive URL). Blank = My Drive root (for Copy: keep the same folder).
- **Shared Drive · Optional**: Destination shared drive id (optional; used when no folder is given).

### Copy

- **File · Required**: The file id (or a Drive URL).
- **Name · Optional**: File name (blank keeps the original / a default).
- **Parent Folder · Optional**: Destination folder id (or a Drive URL). Blank = My Drive root (for Copy: keep the same folder).
- **Shared Drive · Optional**: Destination shared drive id (optional; used when no folder is given).
- **Description · Optional**: A short description for the copied file.
- **Copy Requires Writer Permission · Optional**: Disable copy/print/download of the copy for readers and commenters. Off by default.

### Move

- **File · Required**: The file id (or a Drive URL).
- **Parent Folder · Optional**: Destination folder id (or a Drive URL). Blank = My Drive root (for Copy: keep the same folder).
- **Shared Drive · Optional**: Destination shared drive id (optional; used when no folder is given).

### Share

- **File · Required**: The file id (or a Drive URL).
- **Role · Required**: The access level to grant. Options: Reader, Commenter, Writer, File Organizer, Organizer, Owner. Default: Reader.
- **Type · Required**: Who the permission is for. Options: User, Group, Domain, Anyone. Default: User.
- **Domain · Required**: The domain to share with (such as example.com). Shows when **Type** is **Domain**.
- **Email Address · Required**: The user/group email to share with. Shows when **Type** is **User** or **Group**.
- **Allow File Discovery · Optional**: Let the file surface in search results for the domain/anyone. Off by default. Shows when **Type** is **Domain** or **Anyone**.
- **Send Notification Email · Optional**: Email the person you're sharing with. Off by default.
- **Transfer Ownership · Optional**: Transfer ownership to the user (role must be owner). Off by default.
- **Move to New Owner's Root · Optional**: On ownership transfer, move the file to the new owner's My Drive root. Off by default.
- **Email Message · Optional**: A custom message for the notification email.
- **Use Domain Admin Access · Optional**: Perform the share as a domain administrator. Off by default.

### Update

- **File · Required**: The file id (or a Drive URL).
- **Name · Optional**: File name (blank keeps the original / a default).
- **Replace File Content · Optional**: Also overwrite the file's binary content (from a file object). Off by default.
- **New File Content · Optional**: A file object / data URL / base64 to replace the content with. Shows when **Replace File Content** is on.

### Delete

- **File · Required**: The file id (or a Drive URL).
- **Delete Permanently · Optional**: Permanently delete instead of moving to the trash. Off by default.

### Google Drive › Folder

### Create

- **Folder Name · Required**: Name for the new folder. Default: Untitled.
- **Parent Folder · Optional**: Parent folder id (or a Drive URL). Blank = My Drive root.
- **Shared Drive · Optional**: Parent shared drive id (optional; used when no parent folder is given).
- **Folder Color (RGB) · Optional**: Optional folder color as a hex code, such as #4986e7.

### Share

- **Folder · Required**: The folder id (or a Drive URL).
- **Role · Required**: The access level to grant. Options: Reader, Commenter, Writer, File Organizer, Organizer, Owner. Default: Reader.
- **Type · Required**: Who the permission is for. Options: User, Group, Domain, Anyone. Default: User.
- **Domain · Required**: The domain to share with (such as example.com). Shows when **Type** is **Domain**.
- **Email Address · Required**: The user/group email to share with. Shows when **Type** is **User** or **Group**.
- **Allow File Discovery · Optional**: Let the file surface in search results for the domain/anyone. Off by default. Shows when **Type** is **Domain** or **Anyone**.
- **Send Notification Email · Optional**: Email the person you're sharing with. Off by default.
- **Transfer Ownership · Optional**: Transfer ownership to the user (role must be owner). Off by default.
- **Move to New Owner's Root · Optional**: On ownership transfer, move the file to the new owner's My Drive root. Off by default.
- **Email Message · Optional**: A custom message for the notification email.
- **Use Domain Admin Access · Optional**: Perform the share as a domain administrator. Off by default.

### Delete

- **Folder · Required**: The folder id (or a Drive URL).
- **Delete Permanently · Optional**: Permanently delete instead of moving to the trash. Off by default.

### Google Drive › File/Folder (Search)

### Search

- **Search Method · Optional**: Match by name, or write a full Google Drive search query. Options: Name contains, Advanced query. Default: Name contains.
- **Search Query · Optional**: The text to search for (or a raw Drive query when Search Method is Advanced).
- **Return All · Optional**: Fetch every page of results. Off by default.
- **Limit · Optional**: Max results when not returning all. Default: 50. Shows when **Return All** is off.
- **File Types · Optional**: Only return items of these types (optional, blank = any). Options: Google Docs, Google Sheets, Google Slides, Folders, PDF, JPEG, PNG, MP4 Video, MP3 Audio.
- **What to Search · Optional**: Limit results to files, folders, or both. Options: All, Files only, Folders only. Default: All.
- **In Folder · Optional**: Only return direct children of this folder id (optional).
- **In Shared Drive · Optional**: Restrict the search to this shared drive id (optional).
- **Include Trashed · Optional**: Include items in the trash. Off by default.

### Google Drive › Shared Drive

### Create

- **Name · Required**: Name for the shared drive.
- **Color (RGB) · Optional**: Drive color as a hex code, such as #4986e7.
- **Hidden · Optional**: Hide the shared drive from the default view. Off by default.
- **Admin-Managed Restrictions · Optional**: Only an administrator may change restrictions. Off by default.
- **Copy Requires Writer Permission · Optional**: Disable copy/print/download for readers/commenters. Off by default.
- **Domain Users Only · Optional**: Restrict access to users of the same domain. Off by default.
- **Drive Members Only · Optional**: Restrict access to members of this shared drive. Off by default.

### Get

- **Shared Drive · Required**: The shared drive id.
- **Use Domain Admin Access · Optional**: Issue the request as a domain administrator. Off by default.

### Get Many

- **Return All · Optional**: Fetch every page of shared drives. Off by default.
- **Limit · Optional**: Max shared drives to return when not returning all. Default: 100. Shows when **Return All** is off.
- **Query · Optional**: Optional shared-drive search query (Google Drive query syntax).
- **Use Domain Admin Access · Optional**: Issue the request as a domain administrator. Off by default.

### Update

- **Shared Drive · Required**: The shared drive id.
- **Name · Optional**: New name for the shared drive.
- **Color (RGB) · Optional**: Drive color as a hex code, such as #4986e7.
- **Admin-Managed Restrictions · Optional**: Only an administrator may change restrictions. Off by default.
- **Copy Requires Writer Permission · Optional**: Disable copy/print/download for readers/commenters. Off by default.
- **Domain Users Only · Optional**: Restrict access to users of the same domain. Off by default.
- **Drive Members Only · Optional**: Restrict access to members of this shared drive. Off by default.

### Delete

- **Shared Drive · Required**: The shared drive id.

Source: https://docs.gorunner.io/apps/google-drive
