Googledrive

Learn how to use Googledrive with Composio

Overview

SLUG: GOOGLEDRIVE

Description

Google Drive is a cloud storage solution for uploading, sharing, and collaborating on files across devices, with robust search and offline access

Authentication Details

client_id
stringRequired
client_secret
stringRequired
oauth_redirect_uri
stringDefaults to https://backend.composio.dev/api/v1/auth-apps/add
scopes
stringDefaults to https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/userinfo.email
bearer_token
string
token
stringRequired

Connecting to Googledrive

Create an auth config

Use the dashboard to create an auth config for the Googledrive toolkit. This allows you to connect multiple Googledrive accounts to Composio for agents to use.

1

Select App

Navigate to the Googledrive toolkit page and click “Setup Integration”.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Integration”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using OAuth2

1from composio import Composio
2from composio.types import auth_scheme
3
4# Replace these with your actual values
5googledrive_auth_config_id = "ac_YOUR_GOOGLEDRIVE_CONFIG_ID" # Auth config ID created above
6user_id = "0000-0000-0000" # UUID from database/application
7
8composio = Composio()
9
10
11def authenticate_toolkit(user_id: str, auth_config_id: str):
12 connection_request = composio.connected_accounts.initiate(
13 user_id=user_id,
14 auth_config_id=auth_config_id,
15 )
16
17 print(
18 f"Visit this URL to authenticate Googledrive: {connection_request.redirect_url}"
19 )
20
21 # This will wait for the auth flow to be completed
22 connection_request.wait_for_connection(timeout=15)
23 return connection_request.id
24
25
26connection_id = authenticate_toolkit(user_id, googledrive_auth_config_id)
27
28# You can also verify the connection status using:
29connected_account = composio.connected_accounts.get(connection_id)
30print(f"Connected account: {connected_account}")

Using Bearer Token

1from composio import Composio
2from composio.types import auth_scheme
3
4# Auth config ID created above
5googledrive_auth_config_id = "ac_YOUR_GOOGLEDRIVE_CONFIG_ID"
6
7# UUID from database/application
8user_id = "0000-0000-0000"
9
10composio = Composio()
11
12
13def authenticate_toolkit(user_id: str, auth_config_id: str):
14 # Replace this with a method to retrieve the Bearer Token from the user.
15 bearer_token = input("[!] Enter bearer token")
16 connection_request = composio.connected_accounts.initiate(
17 user_id=user_id,
18 auth_config_id=auth_config_id,
19 config={"auth_scheme": "BEARER_TOKEN", "val": bearer_token}
20 )
21 print(f"Successfully connected Googledrive for user {user_id}")
22 print(f"Connection status: {connection_request.status}")
23
24 return connection_request.id
25
26
27connection_id = authenticate_toolkit(user_id, googledrive_auth_config_id)
28
29# You can verify the connection using:
30connected_account = composio.connected_accounts.get(connection_id)
31print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Googledrive toolkit’s playground

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["GOOGLEDRIVE"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Create Comment

Description

Tool to create a comment on a file. use when you need to add a new comment to a specific file in google drive.

Action Parameters

anchor
string
content
stringRequired
file_id
stringRequired
quoted_file_content_mime_type
string
quoted_file_content_value
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Shared Drive

Description

Tool to create a new shared drive. use when you need to programmatically create a new shared drive for collaboration or storage.

Action Parameters

backgroundImageFile
object
colorRgb
string
hidden
boolean
name
stringRequired
requestId
stringRequired
themeId
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create File or Folder

Description

Creates a new file or folder with metadata. use to create empty files or folders, or files with content by providing it in the request body (though this action primarily focuses on metadata creation).

Action Parameters

description
string
fields
string
mimeType
string
name
string
parents
array
starred
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create a folder

Description

Creates a new folder in google drive, optionally within a parent folder specified by its id or name; if a parent name is provided but not found, the action will fail.

Action Parameters

folder_name
stringRequired
parent_id
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Reply

Description

Tool to create a reply to a comment in google drive. use when you need to respond to an existing comment on a file.

Action Parameters

action
string
comment_id
stringRequired
content
stringRequired
fields
string
file_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Shortcut to File/Folder

Description

Tool to create a shortcut to a file or folder in google drive. use when you need to link to an existing drive item from another location without duplicating it.

Action Parameters

ignoreDefaultVisibility
boolean
includeLabels
string
includePermissionsForView
string
keepRevisionForever
boolean
name
stringRequired
supportsAllDrives
boolean
target_id
stringRequired
target_mime_type
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Comment

Description

Deletes a comment from a file. use when you need to remove a specific comment from a google drive file.

Action Parameters

comment_id
stringRequired
file_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Shared Drive

Description

Tool to permanently delete a shared drive. use when you need to remove a shared drive and its contents (if specified).

Action Parameters

allowItemDeletion
boolean
driveId
stringRequired
useDomainAdminAccess
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Permission

Description

Deletes a permission from a file by permission id. use when you need to revoke access for a specific user or group from a file.

Action Parameters

file_id
stringRequired
permission_id
stringRequired
supportsAllDrives
boolean
useDomainAdminAccess
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Reply

Description

Tool to delete a specific reply by reply id. use when you need to remove a reply from a comment on a file.

Action Parameters

comment_id
stringRequired
file_id
stringRequired
reply_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Download a file from Google Drive

Description

Downloads a file from google drive by its id. for google workspace documents (docs, sheets, slides), optionally exports to a specified `mime type`. for other file types, downloads in their native format regardless of mime type.

Action Parameters

file_id
stringRequired
mime_type
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Empty Trash

Description

Tool to permanently delete all of the user's trashed files. use when you want to empty the trash in google drive.

Action Parameters

driveId
string
enforceSingleParent
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Modify File Labels

Description

Modifies the set of labels applied to a file. returns a list of the labels that were added or modified. use when you need to programmatically change labels on a google drive file, such as adding, updating, or removing them.

Action Parameters

file_id
stringRequired
kind
stringDefaults to drive#modifyLabelsRequest
label_modifications
arrayRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Generate File IDs

Description

Generates a set of file ids which can be provided in create or copy requests. use when you need to pre-allocate ids for new files or copies.

Action Parameters

count
integer
space
string
type
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get About Information

Description

Tool to retrieve information about the user, the user's drive, and system capabilities. use when you need to check storage quotas, user details, or supported import/export formats.

Action Parameters

fields
stringDefaults to *

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Changes Start Page Token

Description

Tool to get the starting pagetoken for listing future changes in google drive. use this when you need to track changes to files and folders.

Action Parameters

driveId
string
supportsAllDrives
boolean
supportsTeamDrives
boolean
teamDriveId
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Comment

Description

Tool to get a comment by id. use when you need to retrieve a specific comment from a google drive file and have both the file id and comment id.

Action Parameters

commentId
stringRequired
fileId
stringRequired
includeDeleted
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Shared Drive

Description

Tool to get a shared drive by id. use when you need to retrieve information about a specific shared drive.

Action Parameters

drive_id
stringRequired
use_domain_admin_access
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get File Metadata

Description

Tool to get a file's metadata by id. use when you need to retrieve the metadata for a specific file in google drive.

Action Parameters

acknowledgeAbuse
boolean
fileId
stringRequired
includeLabels
string
includePermissionsForView
string
supportsAllDrives
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Permission

Description

Gets a permission by id. use this tool to retrieve a specific permission for a file or shared drive.

Action Parameters

file_id
stringRequired
permission_id
stringRequired
supports_all_drives
boolean
use_domain_admin_access
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Reply

Description

Tool to get a specific reply to a comment on a file. use when you need to retrieve the details of a particular reply.

Action Parameters

commentId
stringRequired
fileId
stringRequired
includeDeleted
boolean
replyId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Revision

Description

Tool to get a specific revision's metadata by revision id. use when you need to retrieve information about a particular version of a file.

Action Parameters

acknowledge_abuse
boolean
file_id
stringRequired
revision_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Hide Shared Drive

Description

Tool to hide a shared drive from the default view. use when you want to remove a shared drive from the user's main google drive interface without deleting it.

Action Parameters

drive_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Changes

Description

Tool to list the changes for a user or shared drive. use when you need to track modifications to files and folders, such as creations, deletions, or permission changes. this action requires a `pagetoken` which can be initially obtained using the `get changes start page token` action or from a previous `list changes` response.

Action Parameters

driveId
string
includeCorpusRemovals
boolean
includeItemsFromAllDrives
boolean
includeLabels
string
includePermissionsForView
string
includeRemoved
booleanDefaults to True
pageSize
integerDefaults to 100
pageToken
stringRequired
restrictToMyDrive
boolean
spaces
stringDefaults to drive
supportsAllDrives
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Comments

Description

Tool to list all comments for a file in google drive. use when you need to retrieve comments associated with a specific file.

Action Parameters

fields
stringDefaults to *
fileId
stringRequired
includeDeleted
boolean
pageSize
integerDefaults to 20
pageToken
string
startModifiedTime
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Files and Folders

Description

Tool to list a user's files and folders in google drive. use this to search or browse for files and folders based on various criteria.

Action Parameters

corpora
string
driveId
string
fields
string
includeItemsFromAllDrives
boolean
includeLabels
string
includePermissionsForView
string
orderBy
string
pageSize
integerDefaults to 100
pageToken
string
q
string
spaces
string
supportsAllDrives
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List File Labels

Description

Tool to list the labels on a file. use when you need to retrieve all labels associated with a specific file in google drive.

Action Parameters

file_id
stringRequired
max_results
integer
page_token
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Permissions

Description

Tool to list a file's permissions. use when you need to retrieve all permissions associated with a specific file or shared drive.

Action Parameters

fileId
stringRequired
includePermissionsForView
string
pageSize
integer
pageToken
string
supportsAllDrives
boolean
useDomainAdminAccess
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Replies to Comment

Description

Tool to list replies to a comment in google drive. use this when you need to retrieve all replies associated with a specific comment on a file.

Action Parameters

comment_id
stringRequired
file_id
stringRequired
include_deleted
boolean
page_size
integer
page_token
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List File Revisions

Description

Tool to list a file's revisions. use when you need to retrieve the revision history of a specific file in google drive.

Action Parameters

fileId
stringRequired
pageSize
integer
pageToken
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Shared Drives

Description

Tool to list the user's shared drives. use when you need to get a list of all shared drives accessible to the authenticated user.

Action Parameters

pageSize
integer
pageToken
string
q
string
useDomainAdminAccess
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Move File

Description

Tool to move a file from one folder to another in google drive. use when you need to reorganize files by changing their parent folder(s).

Action Parameters

add_parents
string
file_id
stringRequired
include_labels
string
include_permissions_for_view
string
keep_revision_forever
boolean
ocr_language
string
remove_parents
string
supports_all_drives
boolean
use_content_as_indexable_text
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Export or download a file

Description

Deprecated: exports google workspace files (max 10mb) to a specified format using `mime type`, or downloads other file types; use `googledrive download file` instead.

Action Parameters

file_id
stringRequired
mime_type
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Stop Watch Channel

Description

Tool to stop watching resources through a specified channel. use this when you want to stop receiving notifications for a previously established watch.

Action Parameters

address
string
channelType
string
expiration
string
id
stringRequired
kind
stringDefaults to api#channel
params
object
payload
boolean
resourceId
stringRequired
resourceUri
string
token
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Unhide Shared Drive

Description

Tool to unhide a shared drive. use when you need to restore a shared drive to the default view.

Action Parameters

driveId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Untrash File

Description

Tool to restore a file from the trash. use when you need to recover a deleted file. this action updates the file's metadata to set the 'trashed' property to false.

Action Parameters

file_id
stringRequired
supportsAllDrives
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Comment

Description

Tool to update an existing comment on a google drive file. use when you need to change the content or status (e.g., resolve) of a comment.

Action Parameters

comment_id
stringRequired
content
string
fields
string
file_id
stringRequired
resolved
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Shared Drive

Description

Tool to update the metadata for a shared drive. use when you need to modify properties like the name, theme, background image, or restrictions of a shared drive.

Action Parameters

backgroundImageFile
object
colorRgb
string
driveId
stringRequired
hidden
boolean
name
string
restrictions
object
themeId
string
useDomainAdminAccess
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update File (Metadata)

Description

Updates file metadata. uses patch semantics (partial update) as per google drive api v3. use this tool to modify attributes of an existing file like its name, description, or parent folders. note: this action currently supports metadata updates only. file content updates require multipart/related upload and are not yet implemented.

Action Parameters

add_parents
string
description
string
file_id
stringRequired
keep_revision_forever
boolean
mime_type
string
name
string
ocr_language
string
remove_parents
string
starred
boolean
supports_all_drives
boolean
use_domain_admin_access
boolean
viewers_can_copy_content
boolean
writers_can_share
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update File Revision Metadata

Description

Updates metadata of a file revision (e.g., keepforever, publish). use this tool to modify the metadata of a specific revision of a file in google drive.

Action Parameters

file_id
stringRequired
keep_forever
boolean
publishAuto
boolean
published
boolean
publishedOutsideDomain
boolean
revision_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Permission

Description

Tool to update a permission with patch semantics. use when you need to modify an existing permission for a file or shared drive.

Action Parameters

enforceExpansiveAccess
boolean
fileId
stringRequired
permission
objectRequired
permissionId
stringRequired
removeExpiration
boolean
supportsAllDrives
boolean
transferOwnership
boolean
useDomainAdminAccess
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Reply

Description

Tool to update a reply to a comment on a google drive file. use when you need to modify the content of an existing reply.

Action Parameters

comment_id
stringRequired
content
stringRequired
fields
string
file_id
stringRequired
reply_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Upload File

Description

Uploads a file (max 5mb) to google drive, moving it to a specified folder if a valid folder id is provided, otherwise uploads to root.

Action Parameters

file_to_upload
objectRequired
folder_to_upload_to
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Watch Drive Changes

Description

Tool to subscribe to changes for a user or shared drive in google drive. use when you need to monitor a google drive for modifications and receive notifications at a specified webhook url.

Action Parameters

address
stringRequired
drive_id
string
expiration
integer
id
stringRequired
include_corpus_removals
boolean
include_items_from_all_drives
boolean
include_labels
string
include_permissions_for_view
string
include_removed
booleanDefaults to True
page_size
integerDefaults to 100
page_token
string
params
object
restrict_to_my_drive
boolean
spaces
stringDefaults to drive
supports_all_drives
boolean
token
string
type
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Add file sharing preference

Description

Modifies sharing permissions for an existing google drive file, granting a specified role to a user, group, domain, or 'anyone'.

Action Parameters

domain
string
email_address
string
file_id
stringRequired
role
stringRequired
type
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Copy file

Description

Duplicates an existing file in google drive, identified by its `file id`.

Action Parameters

file_id
stringRequired
new_title
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create a File from Text

Description

Creates a new file in google drive from provided text content (up to 10mb), supporting various formats including automatic conversion to google workspace types.

Action Parameters

file_name
stringRequired
mime_type
stringDefaults to text/plain
parent_id
string
text_content
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Edit File

Description

Updates an existing google drive file by overwriting its entire content with new text (max 10mb).

Action Parameters

content
stringRequired
file_id
stringRequired
mime_type
stringDefaults to text/plain

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Find file

Description

Tool to list or search for files and folders in google drive. use when you need to find specific files based on query criteria or list contents of a drive/folder.

Action Parameters

corpora
string
driveId
string
fields
stringDefaults to *
includeItemsFromAllDrives
boolean
orderBy
string
pageSize
integerDefaults to 100
pageToken
string
q
string
spaces
stringDefaults to drive
supportsAllDrives
booleanDefaults to True

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Find folder

Description

Tool to find a folder in google drive by its name and optionally a parent folder. use when you need to locate a specific folder to perform further actions like creating files in it or listing its contents.

Action Parameters

full_text_contains
string
full_text_not_contains
string
modified_after
string
name_contains
string
name_exact
string
name_not_contains
string
starred
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete folder or file

Description

Tool to delete a file or folder in google drive. use when you need to permanently remove a specific file or folder using its id. note: this action is irreversible.

Action Parameters

fileId
stringRequired
supportsAllDrives
boolean

Action Response

data
objectRequired
error
string
successful
booleanRequired