Gmail setup
Prerequisites
GMAIL_* in .env — see Configuration. Full checklist: Integration guide.
Connect Gmail (built-in routes)
- Set
GMAIL_CLIENT_ID,GMAIL_CLIENT_SECRET, andGMAIL_REDIRECT_URI(configuration). Redirect URI must match Google Console exactly. - Visit
GET /sanvex/gmail/login. - Google redirects to your callback; Sanvex exchanges the code and stores
access_token/refresh_tokenon the global owner.
GMAIL_SUCCESS_REDIRECT — path to redirect after a successful connect (default /).
Laravel AI agent
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:- Build the authorize URL (or call
$driver->oauth()->getAuthorizationUrl($driver->oauthConfig(), $state)). - Exchange the code with
$driver->oauth()->exchangeCode($code, $driver->oauthConfig())— Google requires client id/secret in the POST body (TokenExchangeAuth::RequestBodyonOAuthProviderConfig).
