Skip to main content

Gmail configuration

Package: sanvex/gmail · Driver id: gmail · Auth: OAuth2 only Tokens are stored in encrypted sv_accounts. The Gmail driver reads access_token from there at runtime.

Google Cloud

  1. Google Cloud Console — create or select a project.
  2. APIs & Services → Library — enable Gmail API.
  3. OAuth consent screen — configure (use External if end users connect their own Gmail).
  4. Credentials → OAuth client ID — type Web application.
  5. Authorized redirect URIs — must match GMAIL_REDIRECT_URI (default {APP_URL}/sanvex/gmail/callback).
Save the Client ID and Client secret for .env.

Environment variables

config/sanvex.php (optional)

Set the variables in .env above — that is enough for most apps. To override defaults in published config:
OAuth routes are available when GMAIL_CLIENT_ID is set.

Google OAuth scopes

The built-in authorize URL requests: For send or delete, customize GmailDriver::oauthConfig() scopes in your app or fork. Authorize follows Google’s web server flow: access_type=offline, prompt=consent. Token exchange is application/x-www-form-urlencoded with client_id and client_secret in the POST body.

Built-in Sanvex OAuth routes

Yes — registered when GMAIL_CLIENT_ID is set (via OAuthRoutes::registerIfConfigured). Default callback uses global owner scope (same as Notion). Token exchange uses form body credentials (Google), not HTTP Basic Auth.

Stored credentials (sv_accounts)

Set SANVEX_KEK in production so tokens are encrypted at rest (Installation).

What the driver reads

Next: Setup · Resources