{"skill":{"slug":"gsuite-sdk","displayName":"Gsuite Sdk","summary":"Interact with Google Workspace APIs (Gmail, Calendar, Drive, Sheets) using gsuite-sdk.","description":"---\nname: gsuite-sdk\ndescription: Interact with Google Workspace APIs (Gmail, Calendar, Drive, Sheets) using gsuite-sdk.\nmetadata:\n  openclaw:\n    requires:\n      env:\n        - GOOGLE_CREDENTIALS_FILE\n    primaryEnv: GOOGLE_CREDENTIALS_FILE\n    install:\n      - kind: pip\n        package: gsuite-sdk\n        bins: [gsuite]\n    homepage: https://github.com/PabloAlaniz/google-suite\n---\n\n# Google Suite Skill\n\nSkill para interactuar con Google Workspace APIs (Gmail, Calendar, Drive, Sheets) usando `gsuite-sdk`.\n\n## Instalación\n\n```bash\npip install gsuite-sdk\n```\n\nCon extras opcionales:\n```bash\npip install gsuite-sdk[cloudrun]  # Para Secret Manager\npip install gsuite-sdk[all]       # Todas las dependencias\n```\n\n## Autenticación\n\n### Primera vez (requiere navegador)\n\nEl usuario debe obtener `credentials.json` de Google Cloud Console y luego autenticarse:\n\n```bash\n# Via CLI\ngsuite auth login\n\n# O via Python (abre navegador)\nfrom gsuite_core import GoogleAuth\nauth = GoogleAuth()\nauth.authenticate()\n```\n\nVer [GETTING_CREDENTIALS.md](../docs/GETTING_CREDENTIALS.md) para guía completa.\n\n### Sesiones siguientes\n\nUna vez autenticado, los tokens se guardan localmente y se refrescan automáticamente:\n\n```python\nfrom gsuite_core import GoogleAuth\n\nauth = GoogleAuth()\nif auth.is_authenticated():\n    # Listo para usar\n    pass\nelse:\n    # Necesita autenticarse (abre navegador)\n    auth.authenticate()\n```\n\n## Gmail\n\n### Leer mensajes\n\n```python\nfrom gsuite_core import GoogleAuth\nfrom gsuite_gmail import Gmail, query\n\nauth = GoogleAuth()\ngmail = Gmail(auth)\n\n# Mensajes no leídos\nfor msg in gmail.get_unread(max_results=10):\n    print(f\"De: {msg.sender}\")\n    print(f\"Asunto: {msg.subject}\")\n    print(f\"Fecha: {msg.date}\")\n    print(f\"Preview: {msg.body[:200]}...\")\n    print(\"---\")\n\n# Buscar con query builder\nmensajes = gmail.search(\n    query.from_(\"notifications@github.com\") & \n    query.newer_than(days=7)\n)\n\n# Marcar como leído\nmsg.mark_as_read()\n```\n\n### Enviar email\n\n```python\ngmail.send(\n    to=[\"destinatario@example.com\"],\n    subject=\"Asunto del email\",\n    body=\"Contenido del mensaje\",\n)\n\n# Con adjuntos\ngmail.send(\n    to=[\"user@example.com\"],\n    subject=\"Reporte\",\n    body=\"Adjunto el reporte.\",\n    attachments=[\"reporte.pdf\"],\n)\n```\n\n## Calendar\n\n### Leer eventos\n\n```python\nfrom gsuite_core import GoogleAuth\nfrom gsuite_calendar import Calendar\n\nauth = GoogleAuth()\ncalendar = Calendar(auth)\n\n# Eventos de hoy\nfor event in calendar.get_today():\n    print(f\"{event.start.strftime('%H:%M')} - {event.summary}\")\n\n# Próximos 7 días\nfor event in calendar.get_upcoming(days=7):\n    print(f\"{event.start}: {event.summary}\")\n    if event.location:\n        print(f\"  📍 {event.location}\")\n\n# Rango específico\nfrom datetime import datetime\nevents = calendar.get_events(\n    time_min=datetime(2026, 2, 1),\n    time_max=datetime(2026, 2, 28),\n)\n```\n\n### Crear eventos\n\n```python\nfrom datetime import datetime\n\ncalendar.create_event(\n    summary=\"Reunión de equipo\",\n    start=datetime(2026, 2, 15, 10, 0),\n    end=datetime(2026, 2, 15, 11, 0),\n    location=\"Sala de conferencias\",\n)\n\n# Con asistentes\ncalendar.create_event(\n    summary=\"Sync semanal\",\n    start=datetime(2026, 2, 15, 14, 0),\n    end=datetime(2026, 2, 15, 15, 0),\n    attendees=[\"alice@company.com\", \"bob@company.com\"],\n    send_notifications=True,\n)\n```\n\n## Drive\n\n### Listar y descargar archivos\n\n```python\nfrom gsuite_core import GoogleAuth\nfrom gsuite_drive import Drive\n\nauth = GoogleAuth()\ndrive = Drive(auth)\n\n# Listar archivos recientes\nfor file in drive.list_files(max_results=20):\n    print(f\"{file.name} ({file.mime_type})\")\n\n# Buscar\nfiles = drive.list_files(query=\"name contains 'reporte'\")\n\n# Descargar\nfile = drive.get(\"file_id_aqui\")\nfile.download(\"/tmp/archivo.pdf\")\n```\n\n### Subir archivos\n\n```python\n# Subir archivo\nuploaded = drive.upload(\"documento.pdf\")\nprint(f\"Link: {uploaded.web_view_link}\")\n\n# Subir a carpeta específica\nuploaded = drive.upload(\"data.xlsx\", parent_id=\"folder_id\")\n\n# Crear carpeta\nfolder = drive.create_folder(\"Reportes 2026\")\ndrive.upload(\"q1.pdf\", parent_id=folder.id)\n```\n\n## Sheets\n\n### Leer datos\n\n```python\nfrom gsuite_core import GoogleAuth\nfrom gsuite_sheets import Sheets\n\nauth = GoogleAuth()\nsheets = Sheets(auth)\n\n# Abrir spreadsheet\nspreadsheet = sheets.open(\"SPREADSHEET_ID\")\n\n# Leer worksheet\nws = spreadsheet.worksheet(\"Sheet1\")\ndata = ws.get(\"A1:D10\")  # Lista de listas\n\n# Como diccionarios (primera fila = headers)\nrecords = ws.get_all_records()\n# [{\"Nombre\": \"Alice\", \"Edad\": 30}, ...]\n```\n\n### Escribir datos\n\n```python\n# Actualizar celda\nws.update(\"A1\", \"Nuevo valor\")\n\n# Actualizar rango\nws.update(\"A1:C2\", [\n    [\"Nombre\", \"Edad\", \"Ciudad\"],\n    [\"Alice\", 30, \"NYC\"],\n])\n\n# Agregar filas al final\nws.append([\n    [\"Bob\", 25, \"LA\"],\n    [\"Charlie\", 35, \"Chicago\"],\n])\n```\n\n## CLI\n\nSi instalaste `gsuite-cli`:\n\n```bash\n# Autenticación\ngsuite auth login\ngsuite auth status\n\n# Gmail\ngsuite gmail list --unread\ngsuite gmail send --to user@example.com --subject \"Hola\" --body \"Mundo\"\n\n# Calendar\ngsuite calendar today\ngsuite calendar list --days 7\n\n# Drive\ngsuite drive list\ngsuite drive upload archivo.pdf\n\n# Sheets\ngsuite sheets read SPREADSHEET_ID --range \"A1:C10\"\n```\n\n## Notas para agentes\n\n1. **Primera autenticación requiere navegador** - El usuario debe completar OAuth manualmente la primera vez\n2. **Tokens persisten** - Después de autenticar, los tokens se guardan en `tokens.db` y se refrescan automáticamente\n3. **Scopes** - Por defecto pide acceso a Gmail, Calendar, Drive y Sheets. Se puede limitar con `--scopes`\n4. **Errores comunes:**\n   - `CredentialsNotFoundError`: Falta `credentials.json`\n   - `TokenRefreshError`: Token expiró y no se pudo refrescar (re-autenticar)\n   - `NotFoundError`: Recurso no existe o sin permisos\n","topics":["Sdk","Gmail","Calendar"],"tags":{"latest":"0.1.3"},"stats":{"comments":0,"downloads":1395,"installsAllTime":52,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1770828501660,"updatedAt":1778487899210},"latestVersion":{"version":"0.1.3","createdAt":1770828501660,"changelog":"- Initial release of the skill for interacting with Google Workspace APIs (Gmail, Calendar, Drive, Sheets) using gsuite-sdk.\n- Includes setup and authentication instructions, both via CLI and Python.\n- Provides example usage for reading/sending emails, managing calendar events, listing/uploading/downloading Drive files, and reading/writing Google Sheets.\n- Documents environment requirements and installation steps.\n- Details common authentication issues and troubleshooting notes for users.","license":null},"metadata":{"setup":[{"key":"GOOGLE_CREDENTIALS_FILE","required":true}],"os":null,"systems":null},"owner":{"handle":"pabloalaniz","userId":"s176wkhmrvvpn0z1ttdzxg8h0188596b","displayName":"PabloAlaniz","image":"https://avatars.githubusercontent.com/u/68397098?v=4"},"moderation":null}