|
| 1 | +# Case Study: Issue #66 - Full support for Gemini OAuth (subscriptions login) |
| 2 | + |
| 3 | +## Issue Summary |
| 4 | + |
| 5 | +The issue requests full support for Gemini OAuth authentication to enable subscriptions login, similar to the existing Claude Pro/Max OAuth support. Currently, the agent only supports API token authentication for Gemini. |
| 6 | + |
| 7 | +## Timeline of Events |
| 8 | + |
| 9 | +- **December 16, 2025**: Issue #66 opened requesting Gemini OAuth support |
| 10 | +- **Analysis**: The codebase already contains Google OAuth implementation in `src/auth/plugins.ts`, but the scopes were insufficient for Gemini API subscriptions |
| 11 | + |
| 12 | +## Root Cause Analysis |
| 13 | + |
| 14 | +1. **Insufficient OAuth Scopes**: The Google OAuth plugin only included basic scopes (`cloud-platform`, `userinfo.email`, `userinfo.profile`) but lacked the `generative-language.tuning` and `generative-language.retriever` scopes required for Gemini API subscription features. |
| 15 | + |
| 16 | +2. **Scope Mismatch**: While the implementation was present, the scopes didn't match those recommended in the official Gemini API OAuth documentation for advanced features and subscriptions. |
| 17 | + |
| 18 | +3. **Client Credentials**: The client ID and secret were sourced from the Gemini CLI reference, which may not be optimal for API usage, but appear to be compatible. |
| 19 | + |
| 20 | +## Proposed Solution |
| 21 | + |
| 22 | +Updated the `GOOGLE_OAUTH_SCOPES` array in `src/auth/plugins.ts` to include the additional generative-language scopes required for Gemini API subscriptions. |
| 23 | + |
| 24 | +### Code Changes |
| 25 | + |
| 26 | +```typescript |
| 27 | +const GOOGLE_OAUTH_SCOPES = [ |
| 28 | + 'https://www.googleapis.com/auth/cloud-platform', |
| 29 | + 'https://www.googleapis.com/auth/userinfo.email', |
| 30 | + 'https://www.googleapis.com/auth/userinfo.profile', |
| 31 | + 'https://www.googleapis.com/auth/generative-language.tuning', |
| 32 | + 'https://www.googleapis.com/auth/generative-language.retriever', |
| 33 | +]; |
| 34 | +``` |
| 35 | + |
| 36 | +## Implementation Details |
| 37 | + |
| 38 | +- The Google OAuth plugin already supports the full OAuth flow with local server callback |
| 39 | +- The provider logic correctly detects OAuth credentials and uses Bearer token authentication |
| 40 | +- The implementation follows the same pattern as Anthropic OAuth support |
| 41 | + |
| 42 | +## Testing Recommendations |
| 43 | + |
| 44 | +1. Test OAuth login flow: `agent auth login` → select Google → complete OAuth flow |
| 45 | +2. Verify that Gemini models work with OAuth credentials |
| 46 | +3. Confirm that subscription benefits (higher limits, premium features) are accessible |
| 47 | +4. Test fallback to API key when OAuth is not configured |
| 48 | + |
| 49 | +## References |
| 50 | + |
| 51 | +- Reference implementation: `reference-gemini-cli/packages/core/src/code_assist/oauth2.ts` |
| 52 | +- Gemini API OAuth documentation: https://ai.google.dev/gemini-api/docs/oauth |
| 53 | +- Current agent OAuth: `src/auth/plugins.ts` GooglePlugin |
0 commit comments