Skip to content
Back to skills

Gmail Sync

ASecurity

API integration skill that fetches Gmail messages, syncs inbox labels, and processes attachments via the Gmail REST API. Use when fetching new emails, syncing inbox state, triaging unread messages, exporting mail data, or integrating Gmail into automated workflows.

  • 153 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 27, 2026
data-aipythonapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned May 27, 2026

npx -y skills add Alex8791-cyber/cognithor --skill gmail_sync --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gmail Sync?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gmail Sync
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alex8791-cyber-gmail-sync/badge)](https://www.skillsdirectory.com/skills/alex8791-cyber-gmail-sync)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gmail-sync
description: "API integration skill that fetches Gmail messages, syncs inbox labels, and processes attachments via the Gmail REST API. Use when fetching new emails, syncing inbox state, triaging unread messages, exporting mail data, or integrating Gmail into automated workflows."
---

# Gmail Sync

Fetches Gmail messages, syncs labels, and processes attachments via the Gmail REST API using `httpx`. Requires network access.

## Steps

1. **Authenticate** — obtain or refresh the OAuth2 token:
   ```python
   headers = {"Authorization": f"Bearer {access_token}"}
   ```
2. **Fetch new messages** since the last sync timestamp:
   ```python
   async with httpx.AsyncClient() as client:
       resp = await client.get(
           f"{API_BASE}/messages",
           headers=headers,
           params={"q": "after:{last_sync_epoch}"}
       )
       messages = resp.json().get("messages", [])
   ```
3. **Parse each message** — extract sender, subject, body, labels, and attachment metadata
4. **Store locally** — persist parsed data under `$COGNITHOR_HOME/data/gmail/` as JSON
5. **Return summary** — the skill returns `{"data": <parsed_response>}` with message counts

## Example

```
User > Synchronisiere meine Gmail-Inbox
Cognithor > 14 neue Nachrichten synchronisiert (3 ungelesen, 2 mit Anhängen)
         Letzte Synchronisation: 2026-04-20 14:00 UTC
```

## Error Handling

- **401 Unauthorized**: Token expired — trigger OAuth refresh flow before retrying
- **429 Rate Limited**: Back off exponentially (1s, 2s, 4s) up to 3 retries
- **Network timeout**: Log the failure, preserve last-known state, report to user
- **Empty response**: Confirm query parameters are correct; check `last_sync_epoch` is valid

Files in this skill

  • SKILL.md1.7 KB
  • manifest.json98 B
  • skill.py436 B
  • test_skill.py176 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.