{"id":18634,"library":"opencode-antigravity-auth","title":"opencode-antigravity-auth","description":"opencode-antigravity-auth v1.6.0 is an OAuth authentication plugin for the OpenCode IDE, providing access to Google Antigravity services including Gemini 3 Pro and Claude 4.6 models. It handles credential management, token refresh, and request signing. Released in 2025, it follows a monthly release cadence with beta releases for testing. Key differentiators are its deep integration with OpenCode's plugin system and support for the latest Google Antigravity API features. Requires Node >=20 and TypeScript ^5 as a peer dependency. Ships bundled TypeScript definitions.","status":"active","version":"1.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/NoeFabris/opencode-antigravity-auth","tags":["javascript","opencode","google","antigravity","gemini","oauth","plugin","auth","claude","typescript"],"install":[{"cmd":"npm install opencode-antigravity-auth","lang":"bash","label":"npm"},{"cmd":"yarn add opencode-antigravity-auth","lang":"bash","label":"yarn"},{"cmd":"pnpm add opencode-antigravity-auth","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency >=5 for type definitions","package":"typescript","optional":true}],"imports":[{"note":"This package is ESM-only since v1.0. CommonJS require will fail.","wrong":"const antigravityAuth = require('opencode-antigravity-auth')","symbol":"default","correct":"import antigravityAuth from 'opencode-antigravity-auth'"},{"note":"configureAuth is a named export from the main module. There is no subpath export.","wrong":"import { configureAuth } from 'opencode-antigravity-auth/configure'","symbol":"configureAuth","correct":"import { configureAuth } from 'opencode-antigravity-auth'"},{"note":"AuthProvider is a type export. Use 'import type' to avoid bundling issues in TypeScript.","symbol":"AuthProvider","correct":"import type { AuthProvider } from 'opencode-antigravity-auth'"},{"note":"createMiddleware is re-exported from the main entry. No separate middleware module.","wrong":"import { createMiddleware } from 'opencode-antigravity-auth/middleware'","symbol":"createMiddleware","correct":"import { createMiddleware } from 'opencode-antigravity-auth'"}],"quickstart":{"code":"import antigravityAuth from 'opencode-antigravity-auth';\n\n// Initialize the auth plugin with required configuration\nconst auth = antigravityAuth({\n  clientId: process.env.GOOGLE_CLIENT_ID ?? '',\n  clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? '',\n  redirectUri: 'http://localhost:3000/callback',\n  scopes: ['openid', 'email', 'profile'],\n});\n\n// Generate the authorization URL\nconst authUrl = auth.generateAuthUrl();\nconsole.log('Open the following URL in your browser:', authUrl);\n\n// After redirect, exchange the code for tokens\nconst tokens = await auth.exchangeCode('authorization-code-from-query');\nconsole.log('Access token:', tokens.accessToken);\n\n// Use the tokens to make authenticated requests\nconst response = await auth.request('/api/gemini', {\n  method: 'POST',\n  body: JSON.stringify({ prompt: 'Hello' }),\n});\nconsole.log('API response:', await response.json());\n","lang":"typescript","description":"Shows standard OAuth flow: initialize plugin, generate auth URL, exchange code, and make authenticated API request."},"warnings":[{"fix":"Pass a scopes array explicitly: configureAuth({ scopes: ['openid', 'email'] })","message":"Since v1.6.0, the configureAuth function requires an explicit scopes array; previously it defaulted to ['openid']. Scripts relying on the default will fail at runtime.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Ensure both clientId and redirectUri are provided in the configuration object.","message":"In v1.6.0, generateAuthUrl now throws if clientId or redirectUri is missing (was previously ignored).","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Replace getToken(code) with exchangeCode(code).","message":"The getToken method is deprecated in v1.6.0; use exchangeCode instead.","severity":"deprecated","affected_versions":">=1.6.0"},{"fix":"Use import() syntax: const antigravityAuth = await import('opencode-antigravity-auth');","message":"The package uses a .mjs extension for ESM. If your project is CJS, you must use dynamic import() or switch to ESM.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"To avoid logout, do not delete the cache directory unless intentionally resetting credentials.","message":"User tokens are stored in ~/.cache/opencode by default. Clearing this cache will log out the user.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use dynamic import: const antigravityAuth = await import('opencode-antigravity-auth');","cause":"Trying to require() an ESM-only package in a CommonJS project.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/opencode-antigravity-auth/index.mjs not supported."},{"fix":"Ensure the config object includes both clientId and redirectUri.","cause":"configureAuth was called without clientId or redirectUri, causing generateAuthUrl to not be attached.","error":"TypeError: auth.generateAuthUrl is not a function"},{"fix":"Run npm install opencode-antigravity-auth","cause":"The package is not installed or is not in node_modules.","error":"Error: Cannot find module 'opencode-antigravity-auth'"},{"fix":"Verify the authorization code is fresh and passed correctly.","cause":"exchangeCode was called without a valid authorization code, or the code expired.","error":"TypeError: Cannot destructure property 'accessToken' of 'tokens' as it is undefined."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}