AgentSkillsCN

opencode-antigravity-auth-setup

配置 OpenCode + opencode-antigravity-auth 插件,以免费使用 Google OAuth(Antigravity)实现 Gemini/Claude 的自由使用;涵盖认证存储的常见陷阱、经过验证的解决方案,以及结合日志进行故障排除。

SKILL.md
--- frontmatter
name: opencode-antigravity-auth-setup
description: Configure OpenCode + opencode-antigravity-auth plugin to use Google OAuth (Antigravity) for free Gemini/Claude usage; includes auth-store gotchas, verified workaround, and troubleshooting with logs.

Opencode Antigravity Auth Setup

[Created by Codex: 019ba92d-c995-77c0-b090-e9109492f53b]

Overview

Enable OpenCode to call Antigravity-backed models (Gemini 3 + Claude) using Google OAuth tokens, without API keys, via the opencode-antigravity-auth plugin.

Key Findings (What Broke)

  • OpenCode stores provider credentials in ~/.local/share/opencode/auth.json.
  • OpenCode only runs the plugin’s auth.loader for google if a google credential already exists in that auth store.
  • If there is no google credential, OpenCode uses bundled @ai-sdk/google, which requires GOOGLE_GENERATIVE_AI_API_KEY and fails with AI_LoadAPIKeyError.
  • opencode auth login google is not a provider shortcut. opencode auth login [url] treats the arg as a URL and tries /.well-known/opencode (so google causes ERR_INVALID_URL).

Workflow (Verified)

1) Install/enable plugin + models

  • Ensure ~/.config/opencode/opencode.json contains:
    • "plugin": ["opencode-antigravity-auth@beta"]
    • provider "google" models using the antigravity- prefix (recommended).
  • Confirm models are visible:
    • opencode models google

2) Create a google OAuth credential (required for plugin loader)

  • Run opencode auth login (no args).
  • Select provider: Google.
  • Select method: OAuth with Google (Antigravity).
  • Verify:
    • opencode auth list shows Google oauth.

3) Bootstrap workaround (verified)

If ~/.config/opencode/antigravity-accounts.json already exists (refresh tokens saved) but opencode auth list shows no credentials, bootstrap the google OAuth entry:

bash
python ~/.codex/skills/opencode-antigravity-auth-setup/scripts/bootstrap_opencode_google_oauth.py

This writes a minimal stub to ~/.local/share/opencode/auth.json:

  • google.type=oauth
  • google.refresh="<refreshToken>|<projectId>|<managedProjectId>"
  • google.access="", google.expires=0 (the plugin refreshes on first use)

4) Run a model

bash
opencode run "hello" --model=google/antigravity-gemini-3-pro

Troubleshooting

Symptom: AI_LoadAPIKeyError / “Google Generative AI API key is missing”

  • Cause: plugin loader not running (no google credential in ~/.local/share/opencode/auth.json)
  • Fix: run Workflow step (2) or (3)

Symptom: OpenCode shows “Waiting for authorization…” forever

  • Use the manual fallback flow (CLI prompt), or use the bootstrap script above.
  • Check whether OpenCode actually stored the credential:
    • opencode auth list

Symptom: opencode auth login google fails

  • Expected. Use opencode auth login without args.

Reference (Investigation)

  • Read the investigation handoff at references/investigation-opencode-antigravity-auth.md.