feat(auth): support pure service account mode without impersonation#1
Merged
delight-ai-agent merged 1 commit intomainfrom Mar 3, 2026
Merged
feat(auth): support pure service account mode without impersonation#1delight-ai-agent merged 1 commit intomainfrom
delight-ai-agent merged 1 commit intomainfrom
Conversation
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#346 ✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)
carrotRakko
approved these changes
Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mirrors upstream PR steipete#399.
When a service account is configured via
gog auth service-account set, the CLI always setscfg.Subject(the JWTsubclaim), which triggers Domain-Wide Delegation. This makes it impossible to use a service account in "pure" mode — where it accesses only resources explicitly shared with its own email address.This PR skips setting
cfg.Subjectwhen the provided subject matches the service account's ownclient_email. This enables a common automation pattern: share a Drive folder or Calendar with the SA email, and access only those resources — no DWD required.Changes
internal/googleapi/service_account.go— guardcfg.Subjectassignment: only set when subject differs from the SA'sclient_emailinternal/googleapi/service_account_test.go— 3 test cases: pure SA mode, impersonation mode, empty subjectTest plan
go test ./internal/googleapi/— all existing + new tests passgo build ./...— compiles cleanly✍️ Author: Claude Code with @carrotRakko (AI-written, human-approved)