Skip to content

fix(auth): restrict Keep service account to Keep API calls only#414

Merged
steipete merged 1 commit intoopenclaw:mainfrom
jgwesterlund:fix/keep-sa-scope-isolation
Mar 7, 2026
Merged

fix(auth): restrict Keep service account to Keep API calls only#414
steipete merged 1 commit intoopenclaw:mainfrom
jgwesterlund:fix/keep-sa-scope-isolation

Conversation

@jgwesterlund
Copy link
Copy Markdown
Contributor

Summary

  • When only a Keep-specific service account file (keep-sa-*.json) exists (no generic sa-*.json), tokenSourceForServiceAccountScopes falls back to the Keep SA for all API calls, causing 401 errors on Calendar, Gmail, Drive, and other services that should use OAuth
  • This adds a serviceLabel check so Keep SA files are only used when serviceLabel == "keep", allowing other services to correctly fall through to OAuth authentication

Reproduction

  1. Configure OAuth: gog auth add user@domain.com
  2. Configure Keep SA: gog auth keep --key sa.json user@domain.com
  3. Run: gog calendar events primary --today401 Unauthorized (uses Keep SA instead of OAuth)

Test plan

  • go test ./internal/googleapi/... passes
  • Manual test: Calendar uses OAuth after fix
  • Manual test: Keep still uses service account after fix
  • Manual test: Gmail, Drive also work via OAuth

🤖 Generated with Claude Code

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>
@steipete steipete merged commit fae24e3 into openclaw:main Mar 7, 2026
1 check passed
@steipete
Copy link
Copy Markdown
Collaborator

steipete commented Mar 7, 2026

Landed via squash merge onto main, then applied a follow-up fixup on main to add the regression tests and changelog entry that were validated before merge.

  • Gate: make ci
  • Fixup land commit: pending
  • PR merge commit: fae24e3

Thanks @jgwesterlund!

@steipete
Copy link
Copy Markdown
Collaborator

steipete commented Mar 7, 2026

Follow-up landed on main after the merge race:

Thanks @jgwesterlund!

klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
…claw#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>
klodr pushed a commit to klodr/gogcli that referenced this pull request Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants