Google Oauth Callback
curl --request POST \
--url http://localhost:8000/auth/google/callback \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"redirect_uri": "<string>"
}
'import requests
url = "http://localhost:8000/auth/google/callback"
payload = {
"code": "<string>",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"redirect_uri": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
tenant_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
redirect_uri: '<string>'
})
};
fetch('http://localhost:8000/auth/google/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_PORT => "8000",
CURLOPT_URL => "http://localhost:8000/auth/google/callback",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'tenant_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'redirect_uri' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8000/auth/google/callback"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"tenant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"redirect_uri\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8000/auth/google/callback")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"tenant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"redirect_uri\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8000/auth/google/callback")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"tenant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"redirect_uri\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"expires_in": 123,
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"role": "<string>",
"token_type": "bearer",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authentication
Google Oauth Callback
Handle Google OAuth 2.0 callback.
This endpoint:
- Exchanges the authorization code for user information from Google
- Creates or updates the user in the database
- Verifies the user has access to the specified tenant
- Issues a JWT token with user_id, tenant_id, role, and expiration
Args: request: Google OAuth callback request with code and tenant_id db: Async database session
Returns: TokenResponse: JWT token and user information
Raises: HTTPException 400: If Google OAuth validation fails HTTPException 403: If user doesn’t have access to the tenant
POST
/
auth
/
google
/
callback
Google Oauth Callback
curl --request POST \
--url http://localhost:8000/auth/google/callback \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"redirect_uri": "<string>"
}
'import requests
url = "http://localhost:8000/auth/google/callback"
payload = {
"code": "<string>",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"redirect_uri": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
tenant_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
redirect_uri: '<string>'
})
};
fetch('http://localhost:8000/auth/google/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_PORT => "8000",
CURLOPT_URL => "http://localhost:8000/auth/google/callback",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'tenant_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'redirect_uri' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8000/auth/google/callback"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"tenant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"redirect_uri\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8000/auth/google/callback")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"tenant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"redirect_uri\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8000/auth/google/callback")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"tenant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"redirect_uri\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "<string>",
"expires_in": 123,
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"role": "<string>",
"token_type": "bearer",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Body
application/json
Response
Successful Response