{
  "schemaVersion": "1.0",
  "item": {
    "slug": "google-drive",
    "name": "Google Drive",
    "source": "tencent",
    "type": "skill",
    "category": "效率提升",
    "sourceUrl": "https://clawhub.ai/byungkyu/google-drive",
    "canonicalUrl": "https://clawhub.ai/byungkyu/google-drive",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/google-drive",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=google-drive",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "LICENSE.txt"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-23T16:43:11.935Z",
      "expiresAt": "2026-04-30T16:43:11.935Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
        "contentDisposition": "attachment; filename=\"4claw-imageboard-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/google-drive"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/google-drive",
    "agentPageUrl": "https://openagent3.xyz/skills/google-drive/agent",
    "manifestUrl": "https://openagent3.xyz/skills/google-drive/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/google-drive/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Google Drive",
        "body": "Access the Google Drive API with managed OAuth authentication. List, search, create, and manage files and folders."
      },
      {
        "title": "Quick Start",
        "body": "# List files\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://gateway.maton.ai/google-drive/drive/v3/files?pageSize=10')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF"
      },
      {
        "title": "Base URL",
        "body": "https://gateway.maton.ai/google-drive/{native-api-path}\n\nReplace {native-api-path} with the actual Google Drive API endpoint path. The gateway proxies requests to www.googleapis.com and automatically injects your OAuth token."
      },
      {
        "title": "Authentication",
        "body": "All requests require the Maton API key in the Authorization header:\n\nAuthorization: Bearer $MATON_API_KEY\n\nEnvironment Variable: Set your API key as MATON_API_KEY:\n\nexport MATON_API_KEY=\"YOUR_API_KEY\""
      },
      {
        "title": "Getting Your API Key",
        "body": "Sign in or create an account at maton.ai\nGo to maton.ai/settings\nCopy your API key"
      },
      {
        "title": "Connection Management",
        "body": "Manage your Google OAuth connections at https://ctrl.maton.ai."
      },
      {
        "title": "List Connections",
        "body": "python <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections?app=google-drive&status=ACTIVE')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF"
      },
      {
        "title": "Create Connection",
        "body": "python <<'EOF'\nimport urllib.request, os, json\ndata = json.dumps({'app': 'google-drive'}).encode()\nreq = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'application/json')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF"
      },
      {
        "title": "Get Connection",
        "body": "python <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\nResponse:\n\n{\n  \"connection\": {\n    \"connection_id\": \"21fd90f9-5935-43cd-b6c8-bde9d915ca80\",\n    \"status\": \"ACTIVE\",\n    \"creation_time\": \"2025-12-08T07:20:53.488460Z\",\n    \"last_updated_time\": \"2026-01-31T20:03:32.593153Z\",\n    \"url\": \"https://connect.maton.ai/?session_token=...\",\n    \"app\": \"google-drive\",\n    \"metadata\": {}\n  }\n}\n\nOpen the returned url in a browser to complete OAuth authorization."
      },
      {
        "title": "Delete Connection",
        "body": "python <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}', method='DELETE')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF"
      },
      {
        "title": "Specifying Connection",
        "body": "If you have multiple Google Drive connections, specify which one to use with the Maton-Connection header:\n\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://gateway.maton.ai/google-drive/drive/v3/files?pageSize=10')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Maton-Connection', '21fd90f9-5935-43cd-b6c8-bde9d915ca80')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\nIf omitted, the gateway uses the default (oldest) active connection."
      },
      {
        "title": "List Files",
        "body": "GET /google-drive/drive/v3/files?pageSize=10\n\nWith query:\n\nGET /google-drive/drive/v3/files?q=name%20contains%20'report'&pageSize=10\n\nOnly folders:\n\nGET /google-drive/drive/v3/files?q=mimeType='application/vnd.google-apps.folder'\n\nFiles in specific folder:\n\nGET /google-drive/drive/v3/files?q='FOLDER_ID'+in+parents\n\nWith fields:\n\nGET /google-drive/drive/v3/files?fields=files(id,name,mimeType,createdTime,modifiedTime,size)"
      },
      {
        "title": "Get File Metadata",
        "body": "GET /google-drive/drive/v3/files/{fileId}?fields=id,name,mimeType,size,createdTime"
      },
      {
        "title": "Download File Content",
        "body": "GET /google-drive/drive/v3/files/{fileId}?alt=media"
      },
      {
        "title": "Export Google Docs",
        "body": "GET /google-drive/drive/v3/files/{fileId}/export?mimeType=application/pdf"
      },
      {
        "title": "Create File (metadata only)",
        "body": "POST /google-drive/drive/v3/files\nContent-Type: application/json\n\n{\n  \"name\": \"New Document\",\n  \"mimeType\": \"application/vnd.google-apps.document\"\n}"
      },
      {
        "title": "Create Folder",
        "body": "POST /google-drive/drive/v3/files\nContent-Type: application/json\n\n{\n  \"name\": \"New Folder\",\n  \"mimeType\": \"application/vnd.google-apps.folder\"\n}"
      },
      {
        "title": "Update File Metadata",
        "body": "PATCH /google-drive/drive/v3/files/{fileId}\nContent-Type: application/json\n\n{\n  \"name\": \"Renamed File\"\n}"
      },
      {
        "title": "Move File to Folder",
        "body": "PATCH /google-drive/drive/v3/files/{fileId}?addParents=NEW_FOLDER_ID&removeParents=OLD_FOLDER_ID"
      },
      {
        "title": "Delete File",
        "body": "DELETE /google-drive/drive/v3/files/{fileId}"
      },
      {
        "title": "Copy File",
        "body": "POST /google-drive/drive/v3/files/{fileId}/copy\nContent-Type: application/json\n\n{\n  \"name\": \"Copy of File\"\n}"
      },
      {
        "title": "File Uploads",
        "body": "Google Drive supports three upload types depending on file size and whether you need to include metadata."
      },
      {
        "title": "Simple Upload (Media)",
        "body": "For files up to 5MB when you don't need to set metadata.\n\nPOST /google-drive/upload/drive/v3/files?uploadType=media\nContent-Type: text/plain\n\n<file content>\n\nPython Example:\n\nimport urllib.request, os\n\nfile_content = b'Hello, this is file content!'\n\nurl = 'https://gateway.maton.ai/google-drive/upload/drive/v3/files?uploadType=media'\nreq = urllib.request.Request(url, data=file_content, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'text/plain')\nresponse = urllib.request.urlopen(req)"
      },
      {
        "title": "Multipart Upload",
        "body": "For files up to 5MB when you need to include metadata (name, description, etc.).\n\nPOST /google-drive/upload/drive/v3/files?uploadType=multipart\nContent-Type: multipart/related; boundary=boundary\n\n--boundary\nContent-Type: application/json; charset=UTF-8\n\n{\"name\": \"myfile.txt\", \"description\": \"My file\"}\n--boundary\nContent-Type: text/plain\n\n<file content>\n--boundary--\n\nPython Example:\n\nimport urllib.request, os, json\n\nboundary = '----Boundary'\nmetadata = json.dumps({'name': 'myfile.txt', 'description': 'My file'})\nfile_content = 'File content here'\n\nbody = f'''--{boundary}\\r\nContent-Type: application/json; charset=UTF-8\\r\n\\r\n{metadata}\\r\n--{boundary}\\r\nContent-Type: text/plain\\r\n\\r\n{file_content}\\r\n--{boundary}--'''.encode()\n\nurl = 'https://gateway.maton.ai/google-drive/upload/drive/v3/files?uploadType=multipart'\nreq = urllib.request.Request(url, data=body, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', f'multipart/related; boundary={boundary}')\nresponse = urllib.request.urlopen(req)"
      },
      {
        "title": "Resumable Upload (Large Files)",
        "body": "For large files (recommended for files > 5MB). This approach:\n\nInitiates a session - Gets an upload URI\nUploads in chunks - Sends file in pieces\nSupports resume - Can continue from where it left off if interrupted\n\nStep 1: Initiate Upload Session\n\nPOST /google-drive/upload/drive/v3/files?uploadType=resumable\nContent-Type: application/json; charset=UTF-8\nX-Upload-Content-Type: application/octet-stream\nX-Upload-Content-Length: <file_size>\n\n{\"name\": \"large_file.bin\"}\n\nResponse includes Location header with the upload URI.\n\nStep 2: Upload Content\n\nPUT <upload_uri>\nContent-Length: <file_size>\nContent-Type: application/octet-stream\n\n<file content>\n\nPython Example (Complete):\n\nimport urllib.request, os, json\n\nfile_path = '/path/to/large_file.bin'\nfile_size = os.path.getsize(file_path)\n\n# Step 1: Initiate resumable upload session\nurl = 'https://gateway.maton.ai/google-drive/upload/drive/v3/files?uploadType=resumable'\nmetadata = json.dumps({'name': 'large_file.bin'}).encode()\n\nreq = urllib.request.Request(url, data=metadata, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'application/json; charset=UTF-8')\nreq.add_header('X-Upload-Content-Type', 'application/octet-stream')\nreq.add_header('X-Upload-Content-Length', str(file_size))\n\nresponse = urllib.request.urlopen(req)\nupload_uri = response.headers['Location']\n\n# Step 2: Upload file in chunks (e.g., 5MB chunks)\nchunk_size = 5 * 1024 * 1024\nwith open(file_path, 'rb') as f:\n    offset = 0\n    while offset < file_size:\n        chunk = f.read(chunk_size)\n        end = offset + len(chunk) - 1\n\n        req = urllib.request.Request(upload_uri, data=chunk, method='PUT')\n        req.add_header('Content-Length', str(len(chunk)))\n        req.add_header('Content-Range', f'bytes {offset}-{end}/{file_size}')\n\n        response = urllib.request.urlopen(req)\n        offset += len(chunk)\n\nresult = json.load(response)\nprint(f\"Uploaded: {result['id']}\")\n\nResuming Interrupted Uploads:\n\nIf an upload is interrupted, query the upload URI to get current status:\n\nreq = urllib.request.Request(upload_uri, method='PUT')\nreq.add_header('Content-Length', '0')\nreq.add_header('Content-Range', 'bytes */*')\nresponse = urllib.request.urlopen(req)\n# Check Range header in response to get current offset"
      },
      {
        "title": "Update File Content",
        "body": "To update an existing file's content:\n\nPATCH /google-drive/upload/drive/v3/files/{fileId}?uploadType=media\nContent-Type: text/plain\n\n<new file content>\n\nPython Example:\n\nimport urllib.request, os\n\nfile_id = 'YOUR_FILE_ID'\nnew_content = b'Updated file content!'\n\nurl = f'https://gateway.maton.ai/google-drive/upload/drive/v3/files/{file_id}?uploadType=media'\nreq = urllib.request.Request(url, data=new_content, method='PATCH')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'text/plain')\nresponse = urllib.request.urlopen(req)"
      },
      {
        "title": "Upload to Specific Folder",
        "body": "Include the folder ID in the metadata:\n\nmetadata = json.dumps({\n    'name': 'myfile.txt',\n    'parents': ['FOLDER_ID']\n})"
      },
      {
        "title": "Share File",
        "body": "POST /google-drive/drive/v3/files/{fileId}/permissions\nContent-Type: application/json\n\n{\n  \"role\": \"reader\",\n  \"type\": \"user\",\n  \"emailAddress\": \"user@example.com\"\n}"
      },
      {
        "title": "Query Operators",
        "body": "Use in the q parameter:\n\nname = 'exact name'\nname contains 'partial'\nmimeType = 'application/pdf'\n'folderId' in parents\ntrashed = false\nmodifiedTime > '2024-01-01T00:00:00'\n\nCombine with and:\n\nname contains 'report' and mimeType = 'application/pdf'"
      },
      {
        "title": "Common MIME Types",
        "body": "application/vnd.google-apps.document - Google Docs\napplication/vnd.google-apps.spreadsheet - Google Sheets\napplication/vnd.google-apps.presentation - Google Slides\napplication/vnd.google-apps.folder - Folder\napplication/pdf - PDF"
      },
      {
        "title": "JavaScript",
        "body": "const response = await fetch(\n  'https://gateway.maton.ai/google-drive/drive/v3/files?pageSize=10',\n  {\n    headers: {\n      'Authorization': `Bearer ${process.env.MATON_API_KEY}`\n    }\n  }\n);"
      },
      {
        "title": "Python",
        "body": "import os\nimport requests\n\nresponse = requests.get(\n    'https://gateway.maton.ai/google-drive/drive/v3/files',\n    headers={'Authorization': f'Bearer {os.environ[\"MATON_API_KEY\"]}'},\n    params={'pageSize': 10}\n)"
      },
      {
        "title": "Notes",
        "body": "Use fields parameter to limit response data\nPagination uses pageToken from previous response's nextPageToken\nExport is for Google Workspace files only\nUpload Types: Use uploadType=media for simple uploads (up to 5MB), uploadType=multipart for uploads with metadata (up to 5MB), uploadType=resumable for large files (recommended for > 5MB)\nUpload Endpoint: File uploads use /upload/drive/v3/files (note the /upload prefix)\nResumable Uploads: For large files, use resumable uploads with chunked transfer (256KB minimum chunk size, 5MB recommended)\nMax File Size: Google Drive supports files up to 5TB\nIMPORTANT: When using curl commands, use curl -g when URLs contain brackets (fields[], sort[], records[]) to disable glob parsing\nIMPORTANT: When piping curl output to jq or other commands, environment variables like $MATON_API_KEY may not expand correctly in some shell environments. You may get \"Invalid API key\" errors when piping."
      },
      {
        "title": "Error Handling",
        "body": "StatusMeaning400Missing Google Drive connection401Invalid or missing Maton API key429Rate limited (10 req/sec per account)4xx/5xxPassthrough error from Google Drive API"
      },
      {
        "title": "Troubleshooting: API Key Issues",
        "body": "Check that the MATON_API_KEY environment variable is set:\n\necho $MATON_API_KEY\n\nVerify the API key is valid by listing connections:\n\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF"
      },
      {
        "title": "Troubleshooting: Invalid App Name",
        "body": "Ensure your URL path starts with google-drive. For example:\n\nCorrect: https://gateway.maton.ai/google-drive/drive/v3/files\nIncorrect: https://gateway.maton.ai/drive/v3/files"
      },
      {
        "title": "Resources",
        "body": "Drive API Overview\nList Files\nGet File\nCreate File\nUpdate File\nDelete File\nExport File\nUpload Files\nResumable Uploads\nSearch Query Syntax\nMaton Community\nMaton Support"
      }
    ],
    "body": "Google Drive\n\nAccess the Google Drive API with managed OAuth authentication. List, search, create, and manage files and folders.\n\nQuick Start\n# List files\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://gateway.maton.ai/google-drive/drive/v3/files?pageSize=10')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\nBase URL\nhttps://gateway.maton.ai/google-drive/{native-api-path}\n\n\nReplace {native-api-path} with the actual Google Drive API endpoint path. The gateway proxies requests to www.googleapis.com and automatically injects your OAuth token.\n\nAuthentication\n\nAll requests require the Maton API key in the Authorization header:\n\nAuthorization: Bearer $MATON_API_KEY\n\n\nEnvironment Variable: Set your API key as MATON_API_KEY:\n\nexport MATON_API_KEY=\"YOUR_API_KEY\"\n\nGetting Your API Key\nSign in or create an account at maton.ai\nGo to maton.ai/settings\nCopy your API key\nConnection Management\n\nManage your Google OAuth connections at https://ctrl.maton.ai.\n\nList Connections\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections?app=google-drive&status=ACTIVE')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\nCreate Connection\npython <<'EOF'\nimport urllib.request, os, json\ndata = json.dumps({'app': 'google-drive'}).encode()\nreq = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'application/json')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\nGet Connection\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\n\nResponse:\n\n{\n  \"connection\": {\n    \"connection_id\": \"21fd90f9-5935-43cd-b6c8-bde9d915ca80\",\n    \"status\": \"ACTIVE\",\n    \"creation_time\": \"2025-12-08T07:20:53.488460Z\",\n    \"last_updated_time\": \"2026-01-31T20:03:32.593153Z\",\n    \"url\": \"https://connect.maton.ai/?session_token=...\",\n    \"app\": \"google-drive\",\n    \"metadata\": {}\n  }\n}\n\n\nOpen the returned url in a browser to complete OAuth authorization.\n\nDelete Connection\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}', method='DELETE')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\nSpecifying Connection\n\nIf you have multiple Google Drive connections, specify which one to use with the Maton-Connection header:\n\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://gateway.maton.ai/google-drive/drive/v3/files?pageSize=10')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Maton-Connection', '21fd90f9-5935-43cd-b6c8-bde9d915ca80')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\n\nIf omitted, the gateway uses the default (oldest) active connection.\n\nAPI Reference\nList Files\nGET /google-drive/drive/v3/files?pageSize=10\n\n\nWith query:\n\nGET /google-drive/drive/v3/files?q=name%20contains%20'report'&pageSize=10\n\n\nOnly folders:\n\nGET /google-drive/drive/v3/files?q=mimeType='application/vnd.google-apps.folder'\n\n\nFiles in specific folder:\n\nGET /google-drive/drive/v3/files?q='FOLDER_ID'+in+parents\n\n\nWith fields:\n\nGET /google-drive/drive/v3/files?fields=files(id,name,mimeType,createdTime,modifiedTime,size)\n\nGet File Metadata\nGET /google-drive/drive/v3/files/{fileId}?fields=id,name,mimeType,size,createdTime\n\nDownload File Content\nGET /google-drive/drive/v3/files/{fileId}?alt=media\n\nExport Google Docs\nGET /google-drive/drive/v3/files/{fileId}/export?mimeType=application/pdf\n\nCreate File (metadata only)\nPOST /google-drive/drive/v3/files\nContent-Type: application/json\n\n{\n  \"name\": \"New Document\",\n  \"mimeType\": \"application/vnd.google-apps.document\"\n}\n\nCreate Folder\nPOST /google-drive/drive/v3/files\nContent-Type: application/json\n\n{\n  \"name\": \"New Folder\",\n  \"mimeType\": \"application/vnd.google-apps.folder\"\n}\n\nUpdate File Metadata\nPATCH /google-drive/drive/v3/files/{fileId}\nContent-Type: application/json\n\n{\n  \"name\": \"Renamed File\"\n}\n\nMove File to Folder\nPATCH /google-drive/drive/v3/files/{fileId}?addParents=NEW_FOLDER_ID&removeParents=OLD_FOLDER_ID\n\nDelete File\nDELETE /google-drive/drive/v3/files/{fileId}\n\nCopy File\nPOST /google-drive/drive/v3/files/{fileId}/copy\nContent-Type: application/json\n\n{\n  \"name\": \"Copy of File\"\n}\n\nFile Uploads\n\nGoogle Drive supports three upload types depending on file size and whether you need to include metadata.\n\nSimple Upload (Media)\n\nFor files up to 5MB when you don't need to set metadata.\n\nPOST /google-drive/upload/drive/v3/files?uploadType=media\nContent-Type: text/plain\n\n<file content>\n\n\nPython Example:\n\nimport urllib.request, os\n\nfile_content = b'Hello, this is file content!'\n\nurl = 'https://gateway.maton.ai/google-drive/upload/drive/v3/files?uploadType=media'\nreq = urllib.request.Request(url, data=file_content, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'text/plain')\nresponse = urllib.request.urlopen(req)\n\nMultipart Upload\n\nFor files up to 5MB when you need to include metadata (name, description, etc.).\n\nPOST /google-drive/upload/drive/v3/files?uploadType=multipart\nContent-Type: multipart/related; boundary=boundary\n\n--boundary\nContent-Type: application/json; charset=UTF-8\n\n{\"name\": \"myfile.txt\", \"description\": \"My file\"}\n--boundary\nContent-Type: text/plain\n\n<file content>\n--boundary--\n\n\nPython Example:\n\nimport urllib.request, os, json\n\nboundary = '----Boundary'\nmetadata = json.dumps({'name': 'myfile.txt', 'description': 'My file'})\nfile_content = 'File content here'\n\nbody = f'''--{boundary}\\r\nContent-Type: application/json; charset=UTF-8\\r\n\\r\n{metadata}\\r\n--{boundary}\\r\nContent-Type: text/plain\\r\n\\r\n{file_content}\\r\n--{boundary}--'''.encode()\n\nurl = 'https://gateway.maton.ai/google-drive/upload/drive/v3/files?uploadType=multipart'\nreq = urllib.request.Request(url, data=body, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', f'multipart/related; boundary={boundary}')\nresponse = urllib.request.urlopen(req)\n\nResumable Upload (Large Files)\n\nFor large files (recommended for files > 5MB). This approach:\n\nInitiates a session - Gets an upload URI\nUploads in chunks - Sends file in pieces\nSupports resume - Can continue from where it left off if interrupted\n\nStep 1: Initiate Upload Session\n\nPOST /google-drive/upload/drive/v3/files?uploadType=resumable\nContent-Type: application/json; charset=UTF-8\nX-Upload-Content-Type: application/octet-stream\nX-Upload-Content-Length: <file_size>\n\n{\"name\": \"large_file.bin\"}\n\n\nResponse includes Location header with the upload URI.\n\nStep 2: Upload Content\n\nPUT <upload_uri>\nContent-Length: <file_size>\nContent-Type: application/octet-stream\n\n<file content>\n\n\nPython Example (Complete):\n\nimport urllib.request, os, json\n\nfile_path = '/path/to/large_file.bin'\nfile_size = os.path.getsize(file_path)\n\n# Step 1: Initiate resumable upload session\nurl = 'https://gateway.maton.ai/google-drive/upload/drive/v3/files?uploadType=resumable'\nmetadata = json.dumps({'name': 'large_file.bin'}).encode()\n\nreq = urllib.request.Request(url, data=metadata, method='POST')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'application/json; charset=UTF-8')\nreq.add_header('X-Upload-Content-Type', 'application/octet-stream')\nreq.add_header('X-Upload-Content-Length', str(file_size))\n\nresponse = urllib.request.urlopen(req)\nupload_uri = response.headers['Location']\n\n# Step 2: Upload file in chunks (e.g., 5MB chunks)\nchunk_size = 5 * 1024 * 1024\nwith open(file_path, 'rb') as f:\n    offset = 0\n    while offset < file_size:\n        chunk = f.read(chunk_size)\n        end = offset + len(chunk) - 1\n\n        req = urllib.request.Request(upload_uri, data=chunk, method='PUT')\n        req.add_header('Content-Length', str(len(chunk)))\n        req.add_header('Content-Range', f'bytes {offset}-{end}/{file_size}')\n\n        response = urllib.request.urlopen(req)\n        offset += len(chunk)\n\nresult = json.load(response)\nprint(f\"Uploaded: {result['id']}\")\n\n\nResuming Interrupted Uploads:\n\nIf an upload is interrupted, query the upload URI to get current status:\n\nreq = urllib.request.Request(upload_uri, method='PUT')\nreq.add_header('Content-Length', '0')\nreq.add_header('Content-Range', 'bytes */*')\nresponse = urllib.request.urlopen(req)\n# Check Range header in response to get current offset\n\nUpdate File Content\n\nTo update an existing file's content:\n\nPATCH /google-drive/upload/drive/v3/files/{fileId}?uploadType=media\nContent-Type: text/plain\n\n<new file content>\n\n\nPython Example:\n\nimport urllib.request, os\n\nfile_id = 'YOUR_FILE_ID'\nnew_content = b'Updated file content!'\n\nurl = f'https://gateway.maton.ai/google-drive/upload/drive/v3/files/{file_id}?uploadType=media'\nreq = urllib.request.Request(url, data=new_content, method='PATCH')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nreq.add_header('Content-Type', 'text/plain')\nresponse = urllib.request.urlopen(req)\n\nUpload to Specific Folder\n\nInclude the folder ID in the metadata:\n\nmetadata = json.dumps({\n    'name': 'myfile.txt',\n    'parents': ['FOLDER_ID']\n})\n\nShare File\nPOST /google-drive/drive/v3/files/{fileId}/permissions\nContent-Type: application/json\n\n{\n  \"role\": \"reader\",\n  \"type\": \"user\",\n  \"emailAddress\": \"user@example.com\"\n}\n\nQuery Operators\n\nUse in the q parameter:\n\nname = 'exact name'\nname contains 'partial'\nmimeType = 'application/pdf'\n'folderId' in parents\ntrashed = false\nmodifiedTime > '2024-01-01T00:00:00'\n\nCombine with and:\n\nname contains 'report' and mimeType = 'application/pdf'\n\nCommon MIME Types\napplication/vnd.google-apps.document - Google Docs\napplication/vnd.google-apps.spreadsheet - Google Sheets\napplication/vnd.google-apps.presentation - Google Slides\napplication/vnd.google-apps.folder - Folder\napplication/pdf - PDF\nCode Examples\nJavaScript\nconst response = await fetch(\n  'https://gateway.maton.ai/google-drive/drive/v3/files?pageSize=10',\n  {\n    headers: {\n      'Authorization': `Bearer ${process.env.MATON_API_KEY}`\n    }\n  }\n);\n\nPython\nimport os\nimport requests\n\nresponse = requests.get(\n    'https://gateway.maton.ai/google-drive/drive/v3/files',\n    headers={'Authorization': f'Bearer {os.environ[\"MATON_API_KEY\"]}'},\n    params={'pageSize': 10}\n)\n\nNotes\nUse fields parameter to limit response data\nPagination uses pageToken from previous response's nextPageToken\nExport is for Google Workspace files only\nUpload Types: Use uploadType=media for simple uploads (up to 5MB), uploadType=multipart for uploads with metadata (up to 5MB), uploadType=resumable for large files (recommended for > 5MB)\nUpload Endpoint: File uploads use /upload/drive/v3/files (note the /upload prefix)\nResumable Uploads: For large files, use resumable uploads with chunked transfer (256KB minimum chunk size, 5MB recommended)\nMax File Size: Google Drive supports files up to 5TB\nIMPORTANT: When using curl commands, use curl -g when URLs contain brackets (fields[], sort[], records[]) to disable glob parsing\nIMPORTANT: When piping curl output to jq or other commands, environment variables like $MATON_API_KEY may not expand correctly in some shell environments. You may get \"Invalid API key\" errors when piping.\nError Handling\nStatus\tMeaning\n400\tMissing Google Drive connection\n401\tInvalid or missing Maton API key\n429\tRate limited (10 req/sec per account)\n4xx/5xx\tPassthrough error from Google Drive API\nTroubleshooting: API Key Issues\nCheck that the MATON_API_KEY environment variable is set:\necho $MATON_API_KEY\n\nVerify the API key is valid by listing connections:\npython <<'EOF'\nimport urllib.request, os, json\nreq = urllib.request.Request('https://ctrl.maton.ai/connections')\nreq.add_header('Authorization', f'Bearer {os.environ[\"MATON_API_KEY\"]}')\nprint(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))\nEOF\n\nTroubleshooting: Invalid App Name\nEnsure your URL path starts with google-drive. For example:\nCorrect: https://gateway.maton.ai/google-drive/drive/v3/files\nIncorrect: https://gateway.maton.ai/drive/v3/files\nResources\nDrive API Overview\nList Files\nGet File\nCreate File\nUpdate File\nDelete File\nExport File\nUpload Files\nResumable Uploads\nSearch Query Syntax\nMaton Community\nMaton Support"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/byungkyu/google-drive",
    "publisherUrl": "https://clawhub.ai/byungkyu/google-drive",
    "owner": "byungkyu",
    "version": "1.0.6",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/google-drive",
    "downloadUrl": "https://openagent3.xyz/downloads/google-drive",
    "agentUrl": "https://openagent3.xyz/skills/google-drive/agent",
    "manifestUrl": "https://openagent3.xyz/skills/google-drive/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/google-drive/agent.md"
  }
}