---
title: "Google Oauth Start"
method: GET
path: "/auth/oauth/google/start"
---

# Google Oauth Start

`GET /auth/oauth/google/start`

## Request

- Base URL: `https://api.twtapi.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.twtapi.com/auth/oauth/google/start`
- Auth: none declared

OAuth 第一步：生成 state 并 302 跳转到 Google 授权页。

参数 lang：用户界面语言；returnUrl：登录成功后希望回到的前端站内路径。

为什么要用 state：回调请求是从 Google 域名跳回来的，浏览器带不回本站的任何
上下文，所以把「语言 + 回跳地址」连同随机 state 一起存进 Redis，回调时凭 state
取回。state 同时充当 CSRF 令牌，防止别人伪造回调把攻击者的 Google 账号
绑到受害者会话上。
返回：RedirectResponse 到 Google 授权页；未配置 Google 凭证时返回 error(500)。
副作用：写 Redis（state 记录，TTL 10 分钟）。

## Query parameters

- `lang` string
- `returnUrl` string, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/twtapi/apis/twtapi-backend.md) · [All operations](https://skmtc.dev/twtapi/apis/twtapi-backend/llms.txt) · [OpenAPI document](https://skmtc.dev/twtapi/apis/twtapi-backend/revisions/5295976febaf?raw)
