curl --request GET \
--url https://your-instance.example.com/api/email/oauth/callbackimport requests
url = "https://your-instance.example.com/api/email/oauth/callback"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://your-instance.example.com/api/email/oauth/callback', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/email/oauth/callback",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/email/oauth/callback"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://your-instance.example.com/api/email/oauth/callback")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/email/oauth/callback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"message": "Missing code or state",
"error": "bad_request"
}Handle 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.
curl --request GET \
--url https://your-instance.example.com/api/email/oauth/callbackimport requests
url = "https://your-instance.example.com/api/email/oauth/callback"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://your-instance.example.com/api/email/oauth/callback', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/email/oauth/callback",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/email/oauth/callback"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://your-instance.example.com/api/email/oauth/callback")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/email/oauth/callback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"message": "Missing code or state",
"error": "bad_request"
}Query Parameters
Authorization code returned by the provider.
Base64-encoded JSON { userId, organizationId, provider } echoed back by the provider.
Response
Redirect to ${CLIENT_URL}/settings?provider=<name>&status=success on success, or ${CLIENT_URL}/settings?status=error on failure. Frontends should observe the provider and status query parameters on the resulting settings page to surface the outcome to the user.