Google Oauth Callback

OAuth 第二步:处理 Google 回调,换用户信息、建会话,再 302 回前端。

主流程:校验 state(一次性)-> 用 code 换 userinfo -> 校验邮箱已验证 -> 绑定/创建本站用户 -> 风控记录 -> 建 session 并种 cookie -> 跳回 return_url。

参数 code/state 来自 Google 回调 query;error_description 是用户在 Google 侧 点了「拒绝授权」时 Google 带回来的原因。 返回:成功是带 Set-Cookie 的 302;任何失败都 302 回登录页并附 oauth_error 文案。 —— 这里刻意不向外抛 5xx,因为回调是浏览器直接导航,返回 JSON 报错用户看不懂。 副作用:写库(用户/绑定/last_lang/风控事件)、写 Redis(session)、外部 HTTP 请求。

注意:整个流程被一个宽泛的 try/except 包住,异常只记日志、对外统一提示 "Google login failed",避免把栈信息或 token 细节泄露到 URL 上。

get/auth/oauth/google/callback

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/callback
  • Auth: none declared

Query parameters

codestring nullable
statestring nullable
error_descriptionstring nullable

Response

Successful Response

unknown required

Changes

No recorded changes to this operation across all 2 revisions of this API.