# opencode-gemini-oauth

OpenCode plugin for Google Gemini authentication via OAuth. Use your Google AI Pro subscription quota without API billing.

## Features

- OAuth PKCE authentication with Google
- Automatic token refresh
- Request interception and transformation for Antigravity/Code Assist API
- Token storage with secure local file

## Installation

Add to your `opencode.json`:

```json
{
  "plugins": ["opencode-gemini-oauth@latest"]
}
```

Or use the local path for development:

```json
{
  "plugins": ["D:\\git\\opencode-gemini-oauth"]
}
```

## Configuration

In your `opencode.json`, configure the Google provider:

```json
{
  "provider": {
    "google": {
      "npm": "opencode-gemini-oauth"
    }
  }
}
```

## Usage

1. Start OpenCode
2. Select "OAuth with Google (Gemini)" authentication method
3. Complete the OAuth flow in your browser
4. Your Google AI Pro quota will be used for requests

## Supported Models

- `gemini-2.5-pro`
- `gemini-2.5-flash`
- `gemini-2.0-flash`
- And other Gemini models available through your subscription

## How It Works

This plugin:
1. Authenticates via Google OAuth using PKCE flow
2. Stores refresh tokens locally in `%APPDATA%/opencode/gemini-oauth-accounts.json`
3. Intercepts API requests to `generativelanguage.googleapis.com`
4. Transforms them to use the Code Assist endpoint with your OAuth token
5. Automatically refreshes expired tokens

## Credits

Based on the Antigravity OAuth flow used by Google's AI Studio and Cloud Code extensions.

## License

MIT
