Features
- Model-specific quota tracking (Pro and Flash models)
- Automatic OAuth token refresh
- Tier detection (Free, Paid, Workspace, Legacy)
- Project discovery for quota billing
- Status page integration with Google Workspace incidents
Authentication Method
Gemini uses OAuth authentication via Gemini CLI credentials. Browser cookies are not supported.- OAuth Setup
- Token Refresh
OAuth Authentication
Setup:- Install Gemini CLI:
- Authenticate:
- CodexBar reads credentials from
~/.gemini/oauth_creds.json
- Location:
~/.gemini/oauth_creds.json - Required fields:
access_token,id_token,expiry_date - Optional:
refresh_token(for automatic token refresh)
oauth-personal- Personal Google account (supported)- Unknown type - Tries OAuth credentials (supported)
api-key- API key auth (not supported, hard error)vertex-ai- Vertex AI auth (not supported, hard error)
~/.gemini/settings.json.API Endpoints
Quota API
Authorization: Bearer <access_token>
{} if project is unknown.
Returns:
- Quota buckets per model:
remainingFraction(0.0 to 1.0)resetTime(ISO-8601)modelId
Project Discovery
CodexBar discovers the quota project ID via:- Primary:
cloudaicompanionProjectfromloadCodeAssist - Fallback:
Picks project with:
- Name starts with
gen-lang-client* - Or label
generative-language
- Name starts with
Tier Detection
standard-tier→ “Paid”free-tier+hdclaim → “Workspace”free-tier→ “Free”legacy-tier→ “Legacy”
Parsing and Mapping
Quota Buckets
For each model, CodexBar finds the lowestremainingFraction:
percentLeft = remainingFraction * 100
Reset Time
- Parsed as ISO-8601
- Formatted as “Resets in Xh Ym”
UI Mapping
- Primary: Pro models (lowest percent left)
- Secondary: Flash models (lowest percent left)
Plan Detection
- Tier: From
loadCodeAssistresponse - Email: From
id_tokenJWT claims
Status Page Integration
CodexBar monitors Google Workspace incidents for the Gemini product:- Polls Google Workspace Status API
- Displays incident badge on menu bar icon
- Shows incident details in menu
- Click “View Status” to open status page
Troubleshooting
OAuth credentials not found
OAuth credentials not found
Gemini CLI is not authenticated or credentials file is missing.Solution:
- Install Gemini CLI:
npm install -g @google/gemini-cli - Authenticate:
gemini auth login - Verify credentials:
cat ~/.gemini/oauth_creds.json
Unsupported auth type (api-key or vertex-ai)
Unsupported auth type (api-key or vertex-ai)
CodexBar only supports OAuth authentication.Solution:
- Switch to OAuth:
gemini auth login - Select “Personal Google account” when prompted
- Or use the Vertex AI provider instead (for Vertex AI auth)
Token refresh failed
Token refresh failed
The refresh token may be invalid or revoked.Solution:
- Re-authenticate:
gemini auth logout && gemini auth login - Check that
~/.gemini/oauth_creds.jsonincludesrefresh_token
No quota data
No quota data
The quota API may not be returning data for your project.Solution:
- Check that you have access to the Gemini API
- Verify your project has Gemini API enabled
- Try running
gemini /statsin the CLI to verify quota visibility
OAuth client ID/secret extraction failed
OAuth client ID/secret extraction failed
CodexBar couldn’t find the Gemini CLI installation or extract credentials.Solution:
- Verify Gemini CLI is installed:
which gemini - Check installation path:
npm list -g @google/gemini-cli - Reinstall if necessary:
npm install -g @google/gemini-cli
CLI Usage
Key Files
- Status probe:
Sources/CodexBarCore/Providers/Gemini/GeminiStatusProbe.swift
Related Documentation
- Vertex AI Provider - Alternative for Vertex AI auth
- CLI Reference - CLI usage and options
- Provider Authoring - How providers work internally
