danielmiessler / danielmiessler/Fabric

[Feature request]: OAuth authentication support for Google Gemini

Open
#1,911 3 comments 0 reactions 1 assignee Claimed by @ksylvan View on GitHub
enhancement
Dominant language
Go
Stars
43.9k
Forks
4.3k
Avg merge
1d 4h
Merged PRs (30d)
8

Description

### What do you need?

[Contributing-OAuth-Gemini.md](https://github.com/user-attachments/files/24395188/Contributing-OAuth-Gemini.md)
[Google-AI-Pro-vs-Gemini-API.md](https://github.com/user-attachments/files/24395187/Google-AI-Pro-vs-Gemini-API.md)

OAuth authentication support for Google Gemini in Fabric, allowing users to authenticate using their Google account instead of requiring separate API keys.
## Problem Statement
Currently, Fabric only supports API key authentication for Google Gemini. This creates a significant friction point for users who:
1. **Subscribe to Google AI Pro** ($20/month) expecting it to cover all Google AI services
2. **Discover it doesn't cover the Gemini API** used by Fabric
3. **Must pay for both** the subscription AND the Gemini API separately
### Root Cause
Google maintains three separate tiers:
- **Consumer**: Google AI Pro (web interface & CLI)
- **Developer**: Gemini API (requires API keys, separate billing)
- **Enterprise**: Google Cloud (OAuth-based)
These systems don't integrate, leaving users with confusing dual billing.
## Why This Matters
### Financial Impact
Users with Google AI Pro must pay:
- $20/month subscription
- Plus per-request costs for Gemini API
- Result: Unexpected dual billing
### Community Demand
Multiple users have reported this limitation:
- "Why can't I use my Google AI Pro subscription with Fabric?"
- "Do I need to pay twice?"
- "Can Fabric add OAuth support like Anthropic has?"
## Proposed Solution
**Implement OAuth authentication for Gemini**, similar to what Anthropic achieved in v1.4.231.
### Key Requirements
1. Browser-based OAuth flow (PKCE)
2. Automatic token refresh
3. Persistent token storage
4. User setup prompt: "Use OAuth login or API key?"
5. No breaking changes to existing API key authentication
### Reference Implementation
Anthropic's OAuth implementation (PR #1565) provides an excellent pattern:
- Location: `internal/plugins/ai/anthropic/oauth.go`
- Features: PKCE flow, token refresh, persistent storage
- Can be adapted for Gemini with minimal modifications
## Benefits
1. **For Users**: Single unified authentication method
2. **For Google AI Pro Subscribers**: Potential future integration with subscriptions
3. **For Fabric**: Feature parity with Anthropic/Claude
4. **For Community**: Lower barrier to contribution (guide provided)
## Acceptance Criteria
- [ ] Users can authenticate with OAuth during setup
- [ ] OAuth option appears alongside API key option
- [ ] Tokens are stored securely at `~/.config/fabric/.gemini_oauth`
- [ ] Tokens auto-refresh before expiration
- [ ] Both API key and OAuth methods work simultaneously
- [ ] No breaking changes to existing authentication
- [ ] Documentation updated with OAuth setup instructions
- [ ] Unit tests for OAuth flow and token refresh
## Related Issues & PRs
- PR #1565: OAuth Authentication Support for Anthropic
- Anthropic OAuth Implementation Guide
- Google AI Pro vs Gemini API Documentation (provided below)
## Additional Context
### Complete Documentation Provided
Two comprehensive guides have been prepared and are ready to contribute:
1. **Google-AI-Pro-vs-Gemini-API.md** (374 lines, 12 KB)
- Problem explanation
- 4 solution options
- Comparison tables
- Workarounds
- FAQ
- Ready to add to `docs/`
2. **Contributing-OAuth-Gemini.md** (703 lines, 20 KB)
- 5-step implementation guide
- Complete Go code templates (250+ lines)
- Test templates (50+ lines)
- Testing checklist
- PR submission template
- Ready to add to `docs/`
### Implementation Readiness
- ✅ Research phase: Complete
- ✅ Architecture design: Complete
- ✅ Code templates: Complete
- ✅ Testing strategy: Complete
- ✅ Documentation: Complete
**Status**: Ready for development
## References
- [Gemini API Documentation](https://ai.google.dev/)
- [Google OAuth 2.0](https://developers.google.com/identity/protocols/oauth2)
- [Anthropic OAuth PR #1565](https://github.com/danielmiessler/fabric/pull/1565)
- [Fabric Plugin Architecture](https://github.com/danielmiessler/fabric/tree/main/internal/plugins)
## Next Steps
1. ✅ Issue created with complete context
2. 📝 Documentation files ready to contribute separately
3. 🔍 Community can review and discuss
4. 👨‍💻 Developers can use implementation guide
5. 🚀 Feature can be prioritized and scheduled
---
**Issue Metadata:**
- Type: Feature Request
- Complexity: Medium
- Estimated Effort: 8-16 hours development + review
- Priority: Medium (affects active users, high community interest)
- Labels: enhancement, gemini

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.