Email

Handle email OAuth callback

GET
/api/email/oauth/callback

Provider redirect target. Exchanges the authorization code for tokens, persists or refreshes the EmailAccount, sets up mailbox watch (Gmail Pub/Sub or Outlook Graph subscription) when configured, then 302-redirects to the client settings page with ?provider=<name>&status=success|error. This route is public (no bearer auth) - the userId/organizationId come from the signed OAuth state. Only the pre-redirect validation failures surface as JSON (400). On a downstream failure the user is still 302-redirected back to the settings page with status=error.

Query Parameters

code?string

Authorization code returned by the provider.

state?string

Base64-encoded JSON { userId, organizationId, provider } echoed back by the provider.

Response Body

application/json

curl -X GET "https://example.com/api/email/oauth/callback"
Empty