Skip to content

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

Open
jgwesterlund wants to merge 1 commit intosteipete:mainfrom
jgwesterlund:fix/keep-sa-scope-isolation
Open

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

Conversation

@jgwesterlund
Copy link

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>
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.

1 participant