Title: feat: Google Service Account secret type (JWT → Bearer token injection) · Issue #414 · onecli/onecli · GitHub
Open Graph Title: feat: Google Service Account secret type (JWT → Bearer token injection) · Issue #414 · onecli/onecli
X Title: feat: Google Service Account secret type (JWT → Bearer token injection) · Issue #414 · onecli/onecli
Description: Summary Add a google_service_account secret type that lets agents call Google APIs (Drive, Sheets, etc.) authenticated as a GCP service account — without the SA private key ever entering the agent's environment. The gateway holds the SA ...
Open Graph Description: Summary Add a google_service_account secret type that lets agents call Google APIs (Drive, Sheets, etc.) authenticated as a GCP service account — without the SA private key ever entering the agent'...
X Description: Summary Add a google_service_account secret type that lets agents call Google APIs (Drive, Sheets, etc.) authenticated as a GCP service account — without the SA private key ever entering the agent&...
Opengraph URL: https://github.com/onecli/onecli/issues/414
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat: Google Service Account secret type (JWT → Bearer token injection)","articleBody":"## Summary\n\nAdd a `google_service_account` secret type that lets agents call Google APIs (Drive, Sheets, etc.) authenticated as a GCP service account — without the SA private key ever entering the agent's environment.\n\nThe gateway holds the SA JSON key in the vault, signs a short-lived JWT (RS256), exchanges it at `oauth2.googleapis.com/token`, caches the access token, and injects it as a Bearer header into matching requests. This is the same pattern the GitHub App integration already uses (private key → signed JWT → short-lived token → header injection).\n\n## Motivation / use case\n\nMulti-agent setups where different agents need access to *different* Google Drive data. Example: an HR agent and a Dev agent, each assigned (via selective secret mode) a different service account that is a member of only its department's shared drive. Isolation is enforced by Google-side permissions + per-agent secret grants — a compromised agent cannot reach the other department's data, and cannot exfiltrate the key because only the resolved short-lived token ever crosses the gateway.\n\nThe existing OAuth \"apps\" connectors cover human-account flows, and Vertex AI covers `cloud-platform` scope on aiplatform hosts, but there is currently no way to use a plain service account against general Google APIs.\n\n## Design decisions (feedback welcome)\n\n- **Secret, not App.** SA keys are bring-your-own credentials with a user-configurable host pattern, which matches the Secret abstraction\n (host/path matching + injection). Apps are provider integrations with lifecycle management. Happy to discuss if you'd prefer this as an app provider instead.\n- **Token resolution in the connect phase**, mirroring the existing OpenAI OAuth refresh (`connect.rs`), keeping `build_injections()` synchronous.\n- **JWT claims omit `sub`.** `sub` is only meaningful for domain-wide delegation; without DWD it can cause `invalid_grant`. (The Vertex AI path\n keeps `sub` — unchanged.) Shared JWT-exchange logic could be factored out of `refresh_via_service_account()` with `scope`/`sub` parameterized.\n- **Default hostPattern `www.googleapis.com`** (not `*.googleapis.com`), to avoid matching the token endpoint and colliding with Vertex AI hosts. An\n explicit guard also skips injection for `oauth2.googleapis.com` even if a user broadens the pattern.\n- **In-memory token cache** (~50 min TTL, 10 min safety margin), keyed by `secret_id + hash(secret value)` so key rotation invalidates immediately.\n No DB write-back. Note: on the Cloud edition this cache is Redis, meaning short-lived access tokens would transit the shared cache — flagging for review.\n- **Scope hardcoded to `drive.readonly` for MVP**, surfaced in the UI.\n Configurable scopes (via secret metadata) planned as a follow-up.\n- **Metadata stores only `client_email` / `project_id`** — never the private\n key. Tests assert the key does not leak into metadata or error messages.\n\n## Status\n\nImplemented in my fork (yosukekmt/onecli), including validation/service layer, dialog UI with JSON key upload + parsed preview, gateway resolution with the cache behavior above, and unit tests (validation, service layer, and token-resolution cache hit/miss/expiry/rotation via an injected fetcher).\n\nI'd like to submit this as a PR for this.","author":{"url":"https://github.com/yosukekmt","@type":"Person","name":"yosukekmt"},"datePublished":"2026-07-07T02:57:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/414/onecli/issues/414"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:73d222ca-e3bf-d9ce-d1f8-0d283f318d03 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9E9E:2AF233:302343F:4082C81:6A5DB6EB |
| html-safe-nonce | b352f7bdd193b63db7949895d9298087bf67942c2d22c22299556ab8e6387dc7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTlFOjJBRjIzMzozMDIzNDNGOjQwODJDODE6NkE1REI2RUIiLCJ2aXNpdG9yX2lkIjoiODYyMTMzMjk0NzkwNjk2NzI3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d036241bac8c404d85fda99bb510edeb2bb11700e7dbda9d82b4b4083f10b83c |
| hovercard-subject-tag | issue:4824807848 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/onecli/onecli/414/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c9ec0f7141179fd19ea4570e1b065ef1d7e74a333f45965dfad753b791200461/onecli/onecli/issues/414 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c9ec0f7141179fd19ea4570e1b065ef1d7e74a333f45965dfad753b791200461/onecli/onecli/issues/414 |
| og:image:alt | Summary Add a google_service_account secret type that lets agents call Google APIs (Drive, Sheets, etc.) authenticated as a GCP service account — without the SA private key ever entering the agent'... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yosukekmt |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/onecli/onecli git https://github.com/onecli/onecli.git |
| octolytics-dimension-user_id | 263660444 |
| octolytics-dimension-user_login | onecli |
| octolytics-dimension-repository_id | 1175900220 |
| octolytics-dimension-repository_nwo | onecli/onecli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1175900220 |
| octolytics-dimension-repository_network_root_nwo | onecli/onecli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width