---
title: "Google Callback"
method: GET
path: "/api/v1/auth/google/callback"
tags: ["authentication", "authentication", "google-oauth2"]
---

# Google Callback

`GET /api/v1/auth/google/callback`

## Request

- Base URL: `https://memory.kagura-ai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://memory.kagura-ai.com/api/v1/auth/google/callback`
- Auth: none declared

Handle Google OAuth2 callback.

Exchanges authorization code for access token, retrieves user info,
creates session, and sets HttpOnly cookie.

Args:
    request: FastAPI request (used for IP / User-Agent capture on the
        audit row written by ``RoleManager.ensure_user`` when the IdP-
        provided email differs from the stored value).
    code: OAuth2 authorization code from Google.
    state: CSRF state token (must match stored state).

Returns:
    Redirect to dashboard with session cookie set. Every failure class on
    this browser-facing route 303-redirects to ``/login`` with a
    well-known ``error`` token (#1381) — raw JSON is never the terminal
    state for an interactive user.

Example:
    GET /api/v1/auth/google/callback?code=xxx&state=yyy
    → Sets cookie: kagura_session=...
    → Redirects to /dashboard

Security:
    - State validation (CSRF protection)
    - HttpOnly cookie (XSS protection)
    - Secure cookie (HTTPS only)
    - SameSite=Lax (CSRF protection)

## Query parameters

- `code` string, nullable: OAuth2 authorization code
- `state` string, nullable: CSRF state token
- `error` string, nullable: OAuth2 error code (e.g. access_denied) when the user cancels
- `error_description` string, nullable: Human-readable OAuth2 error detail (not reflected)

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud.md) · [All operations](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/llms.txt) · [OpenAPI document](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/revisions/09f17f5ada29?raw)
