# Google Drive (`onidivo/google-drive`) Actor

Transfer files between Apify's key-value stores and Google Drive.

- **URL**: https://apify.com/onidivo/google-drive.md
- **Developed by:** [Onidivo Technologies](https://apify.com/onidivo) (community)
- **Categories:** Automation
- **Stats:** 51 total users, 1 monthly users, 0.0% runs succeeded, 4 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#rental-actors

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Google Drive

Transfer files between [Apify's key-value stores](https://docs.apify.com/storage#key-value-store) and Google Drive.

- [Input](#input)

  [- Constants (`constants`)](#Constants)

  [- Operations (`operations`)](#Operations)

  [- Is setup mode (`isSetupMode`)](#Is-setup-mode)

  [- Google OAuth credentials (`googleOAuthCredentials`)](#Google-OAuth-credentials)

### Input

The input is a JSON object with the following fields.

| Field | Type | Description | Default value | Possible values | Required |
| ----- | ---- | ----------- | ------ | -------- | -------- |
| constants | array | Constants to use in the operations | - | - | false |
| constants\[*] | object |  Constant settings | - | - | - |
| constants\[name] | string |  Constant name | - | - | true |
| constants\[value] | string or Object |  Constant value | - | - | true |
| operations | array | The operations to execute | - | - | false |
| operations\[*] | Object |  Operation settings, mainly it contains the **type** and other specific settings  | - | - | - |
| fileUploadTimeoutSecs | number |  Maximum available time (in seconds) used to upload a single file | 120 | - | false |
| fileUploadingMaxConcurrency | number |  Maximum concurrency used for uploading files in parallel | - | - | false |
| isSetupMode | boolean |  Whether yes or no to activate the setup mode  | false | - | false |
| googleOAuthTokensStore | string |  Key-value store where your Google OAuth tokens will be stored so you don't have to authorize every time again  | "google-oauth-tokens" | - | false |
| googleOAuthCredentials | object | Google OAuth credentials  | - | - | false |

#### Constants

An array of folder info constants to use by the operations (DRY principle). Each constant is a JSON object composed of two fields: name and value.

##### Constant value as string

Represent the path of the folder

**Example**

```json
{
      "name": "myFolder",
      "value": "my-project/files"
}
```

##### Constant value as object

Provide more folder definition, which can be useful for defining a shared folder.

**Example**

```json
{
      "name": "myFolder",
      "value": {
            "parentFolderId": "GoogleDriveFolderId",
            "path": "files"
      }
}
```

##### Constant usage

We use the constant inside a string with the following format `"constants.[CONSTANT_NAME]"`.

**Example**

```json
  {
      "type": "folders-delete",
      "folder": "constants.myFolder"
  }
```

#### Operations

Operations are the backbone. Each operation is an object and distinguished by the **type** field. The field **type** can have one the following values: **upload**, and **folders-delete**.

For each operation **type** there are specific settings that accompany as explained below:

##### Operation "upload"

Upload files from the key-value stores to a Google Drive folder.

| Field | Type | Description | Default value | Possible values | Required |
| ----- | ---- | ----------- | ------ | -------- | -------- |
| source | object | Represent the file(s) to upload | - | - | true |
| source.idOrName | string | The ID or name of the key-value store  | - | - | true |
| source.forceCloud | boolean | Forcibly use the key-value store from the cloud | false | - | false |
| source.files | array | File(s) to apply the operation on them  |  |  |  |
| source.files\[\*] | object |  File(s) settings | - | - | true |
| source.files\[key] | string |  The key of the file on the key-value store | - | - | true |
| source.files\[name] | string|  The name of upload file on Google Drive | - | - | false |
| source.files\[mimeType] | string |  The Google Drive MIME type of the file | - | [Google Drive MIME types](https://developers.google.com/drive/api/v3/mime-types) | false |
| destination | string / object | Info of the Google Drive's folder where we will upload the file(s) | - | - | true |

**Example**

```json
{
      "type": "upload",
      "source": {
        "idOrName": "my-store",
        "files": [
            {
              "key": "my_spreadsheet",
              "name": "My spreadsheet",
              "mimeType": "application/vnd.google-apps.spreadsheet"
            },
            {
              "key": "my_image",
              "name": "My Image"
            }
        ]
      },
      "destination": "My actor files"
    }
```

##### Operation "folders-delete"

Delete a folder. This operation type is useful for deleting folders before uploading files to prevent file duplication.

| Field | Type | Description | Default value | Possible values | Required |
| ----- | ---- | ----------- | ----- | ---- | ----------- |
| folder | string / object | Info of the Google Drive's folder to delete | - | - | true |

**Example:**

```json
{
      "type": "folders-delete",
      "folder": "My Folder"
}
```

#### Is setup mode

Before you start using the actor for running operations, you will need to run it in the setup mode. To achieve that, you need to run it with the bellow input and follow the steps in the run's log ( for more info, check this [article](https://kb.apify.com/integration/google-integration)).

```json
{
  "isSetupMode": true
}
```

**Note**: If the setup mode is activated, operations will not get executed.

# Actor input Schema

## `constants` (type: `array`):

Constants to use in the operations (JSON array)

## `operations` (type: `array`):

The operations to execute

## `fileUploadTimeoutSecs` (type: `integer`):

Required time to upload a single file. Default is 120.

## `fileUploadingMaxConcurrency` (type: `integer`):

Maximum concurrency used for uploading files in parallel.

## `isSetupMode` (type: `boolean`):

Whether yes or no to activate the setup mode.

## `googleOAuthTokensStore` (type: `string`):

Key-value store where your Google OAuth tokens will be stored so you don't have to authorize every time again. By default it is google-oauth-tokens

## `googleOAuthCredentials` (type: `object`):

If you want to use this actor locally or with your own version, you have to provide your own credentials. Check actor readme for more information.

## Actor input object example

```json
{
  "fileUploadTimeoutSecs": 120,
  "isSetupMode": false,
  "googleOAuthTokensStore": "google-oauth-tokens"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("onidivo/google-drive").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("onidivo/google-drive").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call onidivo/google-drive --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,onidivo/google-drive"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/zb5YRypTcFE5vTTu5/builds/HzUdiZs955Lov6asp/openapi.json
