Skip to content

feat(auth): support env var token injection for op run workflows#1

Open
Leechael wants to merge 1 commit intomainfrom
feat/env-token-injection
Open

feat(auth): support env var token injection for op run workflows#1
Leechael wants to merge 1 commit intomainfrom
feat/env-token-injection

Conversation

@Leechael
Copy link
Owner

@Leechael Leechael commented Feb 9, 2026

Summary

  • Allow bypassing OAuth flow and keyring by setting GOG_CLIENT_ID, GOG_CLIENT_SECRET, and GOG_REFRESH_TOKEN environment variables
  • Enables 1Password CLI (op run) injection of credentials without touching keyring or credentials.json
  • Resolution order: Service Account JSON → Env vars → Keyring
  • Clear error message when token env vars are set but GOG_ACCOUNT is missing

Usage

export GOG_CLIENT_ID="op://vault/item/client_id"
export GOG_CLIENT_SECRET="op://vault/item/client_secret"
export GOG_REFRESH_TOKEN="op://vault/item/refresh_token"
export GOG_ACCOUNT="user@gmail.com"
op run -- gogcli gmail search -q "is:unread"

Files changed

File Change
internal/googleapi/client_env.go New — tokenSourceFromEnv()
internal/googleapi/client_env_test.go New — 5 tests
internal/googleapi/client.go Modified — insert env var path in resolution order
internal/cmd/account.go Modified — guard for missing GOG_ACCOUNT

Test plan

  • go build ./...
  • go test ./internal/googleapi/...
  • Manual: set 3 env vars + GOG_ACCOUNT, run gogcli gmail search, confirm no keyring access

Summary by cubic

Adds env var-based token source so op run can inject Google OAuth credentials without using the keyring or OAuth flow. Service account JSON remains preferred, then env vars, then keyring.

  • New Features
    • Support GOG_CLIENT_ID, GOG_CLIENT_SECRET, and GOG_REFRESH_TOKEN to build an OAuth2 token source from env vars.
    • Works with 1Password CLI (op run) for ephemeral credential injection.
    • Clear error if token env vars are set but GOG_ACCOUNT is missing; set GOG_ACCOUNT or use --account.

Written for commit f0ae9b7. Summary will update on new commits.

Allow bypassing OAuth flow and keyring by setting GOG_CLIENT_ID,
GOG_CLIENT_SECRET, and GOG_REFRESH_TOKEN environment variables.
This enables 1Password CLI (op run) injection of credentials.

Resolution order: Service Account JSON > Env vars > Keyring.
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

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