Commit Graph

52 Commits

Author SHA1 Message Date
Peter Steinberger
c65c88304b
fix: satisfy lint after refactor 2026-05-05 08:52:50 +01:00
Peter Steinberger
cd37734c99
refactor(googleapi): share service constructor setup 2026-05-05 08:48:51 +01:00
Peter Steinberger
8f6791f9f9
refactor(googleapi): expose authenticated HTTP client
Co-authored-by: Ben Lewis <johnbenjaminlewis@gmail.com>
2026-04-28 05:08:14 +01:00
Peter Steinberger
8addfcee8b
fix(auth): backfill account subjects on refresh 2026-04-28 04:19:39 +01:00
Peter Steinberger
68e0e2e6ba
chore(deps): update dependencies 2026-04-20 13:06:44 +01:00
tengis
45c272ffe8
feat(auth): add Application Default Credentials (ADC) auth mode (#357)
* feat: add Application Default Credentials (ADC) auth mode

When GOG_AUTH_MODE=adc, the CLI authenticates using ambient credentials
(GKE Workload Identity, GOOGLE_APPLICATION_CREDENTIALS, or gcloud ADC)
instead of the keyring-based OAuth flow. This enables use in environments
like GKE pods where the service account accesses resources explicitly
shared with it — no domain-wide delegation or user impersonation needed.

The account email is no longer required in ADC mode; requireAccount()
returns "adc" as a placeholder when no --account/GOG_ACCOUNT is set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(auth): add ADC mode (#357) (thanks @tengis617)

* fix(auth): satisfy ADC lint on landed branch (#357)

* test(auth): fix ADC test whitespace lint (#357)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-03-08 17:18:18 +00:00
Dalton Alexandre
1216e6282f feat(admin): add user and group management via Admin Directory API
Implements Google Admin SDK Directory API support for Workspace user and

group management with domain-wide delegation.

New commands:

- gog admin users list --domain example.com

- gog admin users get user@example.com

- gog admin users create user@example.com --given John --family Doe

- gog admin users suspend user@example.com

- gog admin groups list --domain example.com

- gog admin groups members list group@example.com

- gog admin groups members add group@example.com user@example.com --role MEMBER

- gog admin groups members remove group@example.com user@example.com

Closes #340

Note: This is a focused implementation of core user/group management.

For full GAM feature parity (PR #179), additional work would be needed

for: alerts, licenses, org units, printers, reports, vault, SSO, etc.
2026-03-08 02:29:47 +00:00
Fernando Pina dos Santos
380d88c1a2 feat(chat): add messages reactions create/list/delete commands 2026-03-08 02:23:54 +00:00
Peter Steinberger
52e34ac4a7 test(auth): remove rebase marker (#399) (thanks @carrotRakko) 2026-03-08 00:55:48 +00:00
Mitsuyuki Osabe
5919a7ed1e feat(auth): support pure service account mode without impersonation
Skip setting cfg.Subject when the subject matches the service account's
own client_email.  This lets a service account access only resources
explicitly shared with it, without requiring Domain-Wide Delegation.

Closes steipete/gogcli#346

✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
2026-03-08 00:55:48 +00:00
Peter Steinberger
2652d2a65c refactor(auth): simplify account and token-source resolution 2026-03-07 23:48:50 +00:00
Peter Steinberger
11efb052e5 feat(auth): add direct access-token mode (#419) (thanks @mmkal) 2026-03-07 23:39:43 +00:00
Peter Steinberger
a2f001e3df fix(auth): persist rotated refresh tokens (#373) (thanks @joshp123) 2026-03-07 17:57:37 +00:00
the sun gif man
59ab29458c
fix(auth): persist rotated refresh tokens during API calls (#373)
Why
- gogcli refreshed access tokens from a stored refresh token but never wrote back
  a rotated refresh token returned by Google.
- In multi-process CLI usage this can leave keyring state stale across invocations
  and eventually cause invalid_grant when the old token is retired.

What
- add persistingTokenSource wrapper in internal/googleapi/client.go
- wrap oauth2.Config TokenSource in tokenSourceForAccountScopes
- persist rotated refresh token back into secrets store when it changes
- keep persistence failures non-fatal (warn, return token)
- add unit tests for rotate/no-rotate/persist-failure paths

Tests
- go test ./internal/googleapi
2026-03-07 17:57:23 +00:00
Peter Steinberger
484faeae30 fix(auth): isolate Keep service account fallback (#414) (thanks @jgwesterlund) 2026-03-07 16:48:19 +00:00
John Westerlund
fae24e3b1d
fix(auth): restrict Keep service account to Keep API calls only (#414)
When a Keep-specific service account file (keep-sa-*.json) exists,
tokenSourceForServiceAccountScopes falls back to it for all API calls,
not just Keep. This causes 401 errors on Calendar, Gmail, Drive, and
other services that should use OAuth.

Only use keep-sa and legacy Keep SA files when serviceLabel is "keep",
allowing other services to fall through to OAuth authentication.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 16:47:39 +00:00
laihenyi
449beff88b
fix(googleapi): replace Client.Timeout with transport-level ResponseHeaderTimeout (#425)
* feat(drive): include shortcutDetails in drive get fields

Add shortcutDetails to the Drive Get API fields to enable resolving
shortcut target file IDs and MIME types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(googleapi): replace Client.Timeout with transport-level ResponseHeaderTimeout

The global http.Client.Timeout (30s) applied to the entire request
lifecycle, causing large Drive file downloads (videos, backups, etc.)
to time out. Replace it with http.Transport.ResponseHeaderTimeout
which only limits the time waiting for the server to begin responding.
Once response headers arrive and the body starts streaming, there is
no hard cap — large transfers complete naturally.

- Set ResponseHeaderTimeout=30s on the base transport
- Remove http.Client.Timeout from the API client
- Keep a dedicated tokenExchangeTimeout=30s for OAuth2 token refreshes
- Add tests verifying the new transport configuration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 16:44:37 +00:00
Peter Steinberger
7abf494408 fix(ci): clear pre-existing lint baseline and docs updates 2026-03-03 04:06:29 +00:00
Peter Steinberger
e84b243b44 fix: timezone fallback and attachment output hardening
Lands #228.

Co-authored-by: salmonumbrella <182032677+salmonumbrella@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 14:06:25 +01:00
Peter Steinberger
3b2ab325af feat(cli): add forms and appscript commands 2026-02-14 06:24:41 +01:00
Gonçalo Alves
7945602f15
feat: add docs update command for editing Google Docs (#219)
* feat: add docs update command for editing Google Docs

* fix: handle document content range correctly for replace

* docs: add Jarbas avatar

* feat(gogcli): add markdown formatting support for Google Docs

Phase 1 & 2 complete:
- Markdown parser supporting headings, lists, code blocks, blockquotes, links
- Google Docs API integration for formatting
- --format markdown flag for docs update command
- Heading styles (H1-H6), horizontal rules, list indentation
- Code blocks with monospace font

Pending (Phase 3):
- Inline formatting (bold, italic, inline code) - index calculation issues
- Links - index calculation issues

Usage:
  gog docs update <docId> --content-file ./doc.md --format markdown

* fix(gogcli): fix inline formatting indices in markdown formatter

- Simplified document generation to avoid index calculation errors
- Fixed ParseInlineFormatting to correctly track positions
- Preserves: headings, code blocks, blockquotes, lists, horizontal rules

Pending: inline formatting (bold, italic, code, links) - indices still need work

* fix(gogcli): use UTF-16 code units for Google Docs API indexing

- Fixed markdown formatter to use UTF-16 code units instead of UTF-8 bytes
- Added utf16Len() helper function for accurate character counting
- Fixed inline formatting indices (bold, italic, code, links)
- Added empty line handling (MDEmptyLine)
- Successfully tested with Docker course doc (21KB, emojis, diagrams)

This resolves index mismatch errors caused by multi-byte characters like emojis
which are 4 bytes in UTF-8 but 2 code units in UTF-16.

* feat(gogcli): add slides commands with markdown support

- Add 'gog slides update' command with markdown formatting
- Create slides_formatter.go for Google Slides API batch updates
- Create slides_markdown.go for markdown parsing (titles, bullets, code)
- Add slides.go with update/create/read operations
- Update googleauth service for Slides scope

Related: PR #219

* fix(gogcli): use shapes for slides text boxes instead of direct insertion

- Fixed slides creation to use CreateShape with TEXT_BOX instead of inserting text directly
- Direct text insertion into slides is not supported by Google Slides API
- Added title text box with bold 36pt font
- Added body text box for content (bullets, paragraphs, code)
- Supports markdown formatting (bold, bullets, code blocks)

Tested: Successfully created 20-slide presentation from Docker course outline

* feat: add markdown table support (formatted text output)

* feat: implement native Google Docs table insertion with multi-step API

* feat(slides): add --template flag for creating presentations from templates

* fix: stabilize docs/slides markdown + auth flow (#219) (thanks @goncaloalves)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-02-13 22:52:17 +01:00
Peter Steinberger
1a19a27f07 fix(googleapi): honor proxy env in custom OAuth transport 2026-02-13 18:36:58 +01:00
Peter Steinberger
99d957581f feat(auth): add multi-org login
Some checks failed
ci / test (push) Has been cancelled
ci / worker (push) Has been cancelled
ci / darwin-cgo-build (push) Has been cancelled
2026-01-22 04:04:14 +00:00
Peter Steinberger
2b603a81f2 fix(lint): resolve chat lint issues 2026-01-19 02:29:32 +00:00
salmonumbrella
33685adafe feat: add chat support and expand people commands 2026-01-18 05:42:12 +00:00
Peter Steinberger
c3efce4704 chore: switch wsl to v5 2026-01-16 20:12:21 +00:00
salmonumbrella
cb70597f01 feat(classroom): add auth scopes and api client 2026-01-16 10:41:58 +00:00
Peter Steinberger
f2347515d8 fix(keep): use keep.readonly scope (#64) (thanks @jeremys) 2026-01-11 02:24:48 +01:00
Peter Steinberger
3c131fb1e3 feat(auth): support Workspace service accounts (#54) (thanks @pvieito) 2026-01-11 02:09:05 +01:00
Peter Steinberger
ba41885b1c test: raise coverage to 85% 2026-01-09 09:18:16 +01:00
salmonumbrella
f8b83e5609 feat(groups): add Google Groups commands and calendar team feature
- Add `gog groups list` to list groups user belongs to
- Add `gog groups members <email>` to list group members
- Add `gog calendar team <group-email>` for team calendar queries
- Support --freebusy flag for faster availability checks
- Parallel fetching with event deduplication
- Cloud Identity API client for non-admin group access
- Update README with new commands and examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 06:27:58 +01:00
Peter Steinberger
4af95ae7e8 refactor(docs): use docs API for info/cat 2026-01-08 01:16:26 +01:00
Peter Steinberger
b1b9067a23 fix(auth): default --services to user 2026-01-07 21:36:35 +01:00
Elie Habib
1cdd178a04 feat: add Google Keep support (Workspace only)
Add support for Google Keep API with domain-wide delegation for
Google Workspace accounts.

New commands:
- `gog keep list` - list all notes
- `gog keep get <noteId>` - get a specific note
- `gog auth keep <email> --key <path>` - configure service account

The Keep API requires Workspace with domain-wide delegation because
Google restricts the Keep scope to enterprise use. Once configured,
the service account is auto-detected for the specified email.

Features:
- Service account authentication with impersonation
- Auto-detection of stored service account credentials
- JSON output support for scripting
- Manual override with --service-account and --impersonate flags
2026-01-07 21:23:05 +01:00
Peter Steinberger
3c1afc6caf chore: tighten lint rules and fix findings 2025-12-31 19:47:32 +01:00
Peter Steinberger
e616a5b733 chore: tighten lint rules 2025-12-31 17:51:45 +01:00
Peter Steinberger
0a51e93c27 test: expand CLI coverage 2025-12-31 15:36:10 +01:00
Peter Steinberger
348f6d2a05 test: raise coverage and tighten lint 2025-12-31 14:31:49 +01:00
Peter Steinberger
c888a85b1c test: add regression coverage 2025-12-26 19:20:53 +01:00
Peter Steinberger
9d8d36a94e feat: take over PR #18 integration 2025-12-26 15:35:15 +01:00
salmonumbrella
e7fae164f4
feat: add context propagation, security fixes, and new features
Drive:
- Add context propagation to all API calls
- Add path traversal security fix in download

Gmail:
- Add context propagation to labels and thread commands
- Simplify MIME building (remove unused ReplyTo, BodyHTML)
- Add --from flag for send-as aliases in send and drafts
- Simplify base64 decoding
- Add path traversal security fix in attachments

Calendar:
- Add needsAction status support to respond command
- Add --comment flag for response comments
- Add organizer check to prevent self-response

Auth:
- Add browser-based account management command (auth manage)
- Add web UI for managing connected accounts

Maintenance:
- Update golangci-lint config for v2 compatibility
2025-12-24 19:14:01 -08:00
salmonumbrella
d2be673d10
feat: add retry logic, concurrent fetching, and extended commands
Resilience:
- RetryTransport with circuit breaker for 429/5xx resilience
- Exponential backoff with jitter, respects Retry-After headers
- Circuit breaker auto-resets after 30s of successful requests

Performance:
- Concurrent gmail thread fetching (fixes N+1 query pattern)
- Bounded concurrency with semaphore (max 10 parallel)

New calendar commands:
- colors: list available event/calendar colors
- conflicts: check availability across calendars
- search: find events by text query
- time: show current time in multiple timezones

New gmail commands:
- autoforward: get/enable/disable auto-forwarding
- delegates: list/add/remove mail delegation
- filters: list/create/delete inbox filters
- forwarding: manage forwarding addresses
- sendas: manage send-as aliases
- vacation: get/enable/disable vacation responder
- batch: bulk operations (mark-read, archive, label, delete)
- watch: Pub/Sub push with webhook forwarding

New services:
- Sheets: read/write/append spreadsheet data
- Tasks: manage tasklists and tasks

Developer experience:
- Shell completion (bash, zsh, fish, powershell)
- version command with build info
- --debug flag for verbose logging
- lefthook for pre-commit hooks

Documentation:
- Expanded README with examples
- Gmail watch/Pub/Sub guide (docs/watch.md)
- Architecture spec (docs/spec.md)
- Release process (docs/RELEASING.md)
2025-12-24 17:51:21 -08:00
Peter Steinberger
d50d7f7bcc feat(tasks): add Tasks support 2025-12-24 18:50:59 +01:00
Peter Steinberger
4015bc4d91 test: cover drive downloads and gmail helpers 2025-12-12 16:35:41 +00:00
Peter Steinberger
c6e17331d1 test: raise coverage (auth + googleapi + helpers) 2025-12-12 16:32:07 +00:00
Peter Steinberger
f27117ba33 test: raise coverage for drive and googleapi 2025-12-12 16:03:20 +00:00
Peter Steinberger
055b27f9fc Tests: add more coverage for helpers 2025-12-12 15:21:57 +00:00
Peter Steinberger
dbd3846fcc Auth: don't pre-check stored scopes 2025-12-12 15:03:03 +00:00
Peter Steinberger
c0589dca9d OAuth2: bound refresh-token HTTP with timeout 2025-12-12 14:55:19 +00:00
Peter Steinberger
654ce4740f Google API: set default HTTP timeout 2025-12-12 14:51:17 +00:00