Google OAuth

Google Cloud Console OAuth 2.0 接入指南

创建 OAuth 凭据

访问 Google Cloud Console,进入 "APIs & Services" > "Credentials",点击 "Create Credentials" > "OAuth client ID"。

配置 OAuth 同意屏幕

首次创建时需要先配置 OAuth 同意屏幕(OAuth consent screen),选择 "External" 用户类型,填写应用信息。

填写回调 URI

  • Application type 选择 "Web application"
  • Authorized redirect URIs 添加: http://localhost:7001/api/auth/callback/google

配置环境变量

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

Google Cloud Console 里的 "Authorized redirect URIs" 必须和实际回调地址完全一致。多一个斜杠、少一个端口号都会失败。

相关资源

On this page