Skip to content

feat: add DB-backed encrypted Google OAuth token storage - #9

Open
Mustafa-Esoofally wants to merge 9 commits into
mainfrom
feat/google-db-auth
Open

feat: add DB-backed encrypted Google OAuth token storage#9
Mustafa-Esoofally wants to merge 9 commits into
mainfrom
feat/google-db-auth

Conversation

@Mustafa-Esoofally

Copy link
Copy Markdown

Summary

  • Add shared AuthConfig for Gmail + Calendar providers (scope consolidation)
  • Store OAuth tokens in PostgreSQL with Fernet encryption
  • Check DB tokens before falling back to file-based tokens
  • Add migration script to move existing file tokens to DB

Why

Addresses the Google auth pain point mentioned by Ashpreet - no more juggling multiple token files. Single OAuth consent covers all Google services, tokens encrypted and stored in the same DB as everything else.

Setup

Requires GOOGLE_TOKEN_ENCRYPTION_KEY env var for encryption:

# Generate a key
python3 -c "import secrets; print(secrets.token_urlsafe(32))"

# Add to .env
GOOGLE_TOKEN_ENCRYPTION_KEY=<generated-key>

Migration

python scripts/migrate_google_tokens_to_db.py

Test plan

  • Encryption round-trip
  • DB token storage + retrieval
  • Scope aggregation (5 scopes consolidated)
  • Context providers load from DB
  • Gmail API calls work
  • Calendar API calls work
  • 16/16 E2E tests pass

Dependencies

Requires agno PR with auth= param for context providers (feat/google-context-providers-auth)

🤖 Generated with Claude Code

Mustafa-Esoofally and others added 9 commits June 16, 2026 17:24
- Add shared AuthConfig for Gmail + Calendar providers (scope consolidation)
- Store OAuth tokens in PostgreSQL with Fernet encryption
- Check DB tokens before falling back to file-based tokens
- Add migration script to move existing file tokens to DB
- Requires GOOGLE_TOKEN_ENCRYPTION_KEY env var for encryption

Co-Authored-By: Claude <noreply@anthropic.com>
…rage

- Extract provider factories to agents/providers/ (google, slack, core, hardening)
- Slim agents/sources.py to registry + tool hardening only
- Shared AuthConfig for Gmail + Calendar with pre-registered scopes
- DB + encryption as the only path (no file fallback complexity)
- Simplified google_mint_tokens.py with --generate-key option
- Remove migrate_google_tokens_to_db.py (just re-auth instead)
- Bump agno to 2.6.20
Mints encrypted Google OAuth tokens directly to Railway DB.
Creates TCP proxy via Railway GraphQL API if needed.

Usage: python scripts/railway/google_auth.py [--force]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant