OAuth authentication plugin for Google Gemini CLI in OpenCode.
git clone https://github.com/shantur/opencode-gemini-auth.git
cd opencode-gemini-auth
bun installEdit your OpenCode configuration file to add the plugin:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"file:///Users/shantur/Coding/opencode-gemini-auth"
]
}Note: Update the file path to match where you cloned the repository.
opencode auth loginWhen prompted, select "google" or "OAuth with Google (Gemini)" from the authentication methods.
Then follow the OAuth flow:
- A browser window will open
- Complete Google authentication
- Copy the final localhost URL
- Paste it back in the terminal
- ✅ OAuth 2.0 authentication with Google
- ✅ Support for Google Cloud Project ID (optional for free tier)
- ✅ Automatic token refresh
- ✅ Request/response transformation for Cloud Code Assist API
- ✅ Support for both streaming and non-streaming responses
- ✅ Automatic project setup for free tier users
- User selects "OAuth with Google (Gemini)"
- Optionally enters Google Cloud Project ID (not required for free tier)
- Opens OAuth URL in browser
- Completes Google authentication
- Pastes callback URL back into the application
- Plugin handles token exchange and storage
- Node.js >= 18.0.0
- OpenCode AI plugin system
For non-free tier usage, you'll need:
- A Google Cloud Project
- Cloud Code Assist API enabled
Free tier users can skip project setup - the plugin will automatically use Google's managed project.
This plugin transforms requests between:
- From:
generativelanguage.googleapis.com(Generative Language API) - To:
cloudcode-pa.googleapis.com(Cloud Code Assist API)
MIT
@shantur