# plugin_antigravity_login — Google Antigravity login for SCORPIOX BOT `plugin_antigravity_login` is a **zero-dependency C99 node plugin** for [SCORPIOX BOT](https://bot.scorpiox.net). It drives a Google **OAuth 2.0 PKCE** login for **Google Antigravity** on the node it runs on: start the flow, paste the authorization code, run the exchange and the Google Cloud companion‑project discovery, then read the session state, token expiry and project — and refresh the token on demand. * `--meta` → `{"name":"google","desc":"Google login"}` * `--version` → `plugin_antigravity_login 1.0.1` * Catalog slug `antigravity-login`, category `devtools` * Public source: * Prebuilt binaries: Two ways to consume it, both first-class: | Track | What you get | |---|---| | **Source** | `git clone` the repo above, read one C file, compile it on your node in a second, install to `~/.scorpiox/plugins/`. No dependency, no build system beyond `cc`. | | **Prebuilt** | a static binary per platform at `dist.scorpiox.net/bot-plugins/antigravity-login/1.0.1/`, with `manifest.json`, `SHA256SUMS` and the exact `source.tar.gz`. | --- ## Why this plugin has no TLS code and no client secret A PKCE code exchange is an HTTPS POST that carries an OAuth client identity. A public, clean-room repository cannot ship a client secret, and a plugin that re-implemented TLS would be a liability on every node. So this plugin does what SCORPIOX CODE already designed its login tools for: it **drives the machine-mode CLI** that ships with the product. ``` plugin_antigravity_login --popen--> scorpiox-antigravity-login --status --start --finish --cancel --popen--> scorpiox-google-fetchtoken -local ``` Machine mode is the contract documented in `sx_login_machine.h`: one JSON line per call, human progress on stderr/stdout before it, no TTY required. The plugin takes the **last** line that starts with `{`, so the parsers are exercised against the production layout rather than an invented one. The plugin reads (and never writes): | Path | What it is used for | |---|---| | `~/.config/google-accounts/antigravity_accounts.json` | account list + `refresh_token` **presence** | | `~/.config/google-accounts/selected_account.txt` | the active Google account | | `~/.claude/scorpiox-env/antigravity.txt` | `GOOGLE_PROJECT_ID`, `GOOGLE_ACCOUNT` | | `~/.claude/.login-pending/antigravity-default.json` | the pending-flow marker | **No token is ever printed, logged or returned.** `action=status` reports `has_refresh` (a boolean), `expires_at` and `expires_in_sec`. `action=refresh` reports `refreshed: true` and the expiry — the access token the CLI prints is read for presence and discarded, so a browser, a proxy log or a screenshot can never capture a bearer token from this route. The test suite asserts that: a mock token CLI prints `ya29.MOCK-ACCESS-TOKEN-MUST-NOT-LEAK` and the suite fails if the string appears in any response. --- ## Requirements on the node | Platform | Needs | |---|---| | Linux / macOS | `scorpiox-antigravity-login` and `scorpiox-google-fetchtoken` on `PATH` (both ship with SCORPIOX CODE) | | Windows | the same two binaries in `%PATH%` | | any | nothing else — the plugin has **zero** library dependencies | If the CLIs are absent the plugin still serves the UI and answers `action=status` `cli_present:false` with a clear message, so a node without SCORPIOX CODE does not show a broken panel. --- ## Environment overrides (all optional, all for testing or relocation) | Variable | Effect | |---|---| | `ANTIGRAVITY_CREDS_PATH` | the accounts JSON. Its directory also anchors `selected_account.txt` and the profile dir, so a relocated install stays self-consistent. | | `ANTIGRAVITY_ENV_DIR` | the profile directory (default `~/.claude/scorpiox-env`) | | `ANTIGRAVITY_PENDING_PATH` | the pending-flow marker | | `ANTIGRAVITY_LOGIN_BIN` | the login CLI (default `scorpiox-antigravity-login`) | | `ANTIGRAVITY_TOKEN_BIN` | the token CLI (default `scorpiox-google-fetchtoken`) | | `BOT_PASSWORD` | when set, every route except `--meta` requires it | --- ## API All actions are `GET` (or `POST` for `finish`) against the plugin route, with the node password supplied as `X-Bot-Password`, `Authorization: Bearer` or `?pwd=`. ### `?action=status` (also `?format=json`) ```json { "ok": true, "plugin": "plugin_antigravity_login", "version": "1.0.1", "logged_in": true, "email": "someone@example.com", "account": "someone@example.com", "project_id": "proj-mock-42", "profile": "antigravity", "expires_at": 1790000000, "expires_in_sec": 3599, "expired": false, "has_refresh": true, "pending": false, "cli_present": true, "credentials_path": "/root/.config/google-accounts/antigravity_accounts.json" } ``` `expires_at` is unix **seconds** (the CLI's millisecond value is normalised). `expired` is only ever true for a session that exists. ### `?action=start` ```json { "ok": true, "flow": "paste_code", "auth_url": "https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=...&code_challenge=...&code_challenge_method=S256&...", "expires_in": 900, "hint": "Sign in with Google and approve. The browser lands on antigravity.google - copy the whole address (or just the code) and paste it here." } ``` The PKCE verifier lives in the CLI's pending file (mode 0600). The plugin never sees it and never needs it. ### `?action=finish&code=...` (or a POST body `{"code":"..."}`) Accepts a bare code **or** the whole `https://antigravity.google/oauth-callback?...` address; the `code=` value is extracted before validation. On success the response is the full status object with `"state":"done"`. Rejected before anything runs (the code is passed to a shell, so this is a real guard, not a formality): ```json {"ok":false,"error":"invalid_code","detail":"the value is not an authorization code (empty, too long, or contains shell characters)"} ``` Shell metacharacters, quotes, backticks, `$`, `;`, `|`, `&`, `<`, `>` and control bytes are refused; the argument is also single-quoted with the `'\''` escape, and the test suite proves a `$(touch /tmp/pwned)` payload creates no file. ### `?action=cancel` ```json {"ok": true, "state": "cancelled", "pending": false} ``` ### `?action=refresh` Runs `scorpiox-google-fetchtoken -local`, reports success and the new expiry, and **drops the token**: ```json {"ok": true, "refreshed": true, "logged_in": true, "email": "...", "project_id": "...", "expires_in_sec": 3599, ...} ``` Failure is structured, never a stack trace: ```json {"ok": false, "error": "refresh_failed", "detail": "the token CLI could not refresh the session; sign in again"} ``` ### Errors | Error | HTTP | Meaning | |---|---|---| | `invalid node password` | 401 | `BOT_PASSWORD` is set and no credential matched | | `missing_code` | 400 | `finish` without a code | | `invalid_code` | 400 | the value cannot be an authorization code | | `unknown_action` | 404 | unrecognised `action=` | | `cli_unavailable` | 200 | the login/token CLI is not on this node | | `exchange` / `finish_failed` | 200 | Google rejected the code, or the account needs verification | --- ## The UI One page, no framework, no CDN, no `