Skip to main content

Gmail setup

Register the app in Google Cloud and set OAuth credentials — Gmail configuration.

Prerequisites

Set GMAIL_* in .env — see Configuration. Full checklist: Integration guide.

Connect Gmail (built-in routes)

  1. Set GMAIL_CLIENT_ID, GMAIL_CLIENT_SECRET, and GMAIL_REDIRECT_URI (configuration). Redirect URI must match Google Console exactly.
  2. Visit GET /sanvex/gmail/login.
  3. Google redirects to your callback; Sanvex exchanges the code and stores access_token / refresh_token on the global owner.
Optional: GMAIL_SUCCESS_REDIRECT — path to redirect after a successful connect (default /).

Laravel AI agent

Only expose tools after resolveDriver('gmail')->isConfigured() is true. See Laravel AI.

Custom OAuth flow

You only need a custom flow if you want a different owner scope, callback path, or scopes than the driver ships. In that case:
  1. Build the authorize URL (or call $driver->oauth()->getAuthorizationUrl($driver->oauthConfig(), $state)).
  2. Exchange the code with $driver->oauth()->exchangeCode($code, $driver->oauthConfig()) — Google requires client id/secret in the POST body (TokenExchangeAuth::RequestBody on OAuthProviderConfig).
Manual storage (if not using the callback route):

Verify

Resources