开始 Google 登录
在浏览器中跳转至 Google 授权页面。
GET
/api/account/google请求参数
此操作无需提交参数。
请求示例
cURL
curl -i -X GET 'https://social2api.com/api/account/google'Python
from urllib.error import HTTPError
from urllib.request import Request, urlopen
request = Request(
"https://social2api.com/api/account/google",
method="GET",
)
send = urlopen
try:
with send(request) as response:
print(response.status, response.read().decode("utf-8"))
except HTTPError as error:
print(error.code, error.read().decode("utf-8"))JavaScript
const response = await fetch("/api/account/google", {
method: "GET",
});
console.log(response.status, await response.text());响应
303 · 示例响应
无响应正文
错误示例
{
"error": "账户服务暂不可用,请稍后重试。"
}| 字段 | 类型 | 说明 |
|---|---|---|
Location | URI | Google 授权地址。 |
Set-Cookie | header | 提供用于关联回调的短期状态 Cookie。 |
错误状态
| HTTP | 原因与处理 |
|---|---|
403 | 浏览器来源校验未通过。 |
405 | 请求方法不受支持。 |
429 | 尝试次数过多。根据 Retry-After 的秒数再试。 |
500 | 账户服务暂时不可用。 |
503 | Google 登录尚未配置。 |
使用细节
- 账户写请求来自站点同源页面。跨站请求由服务器拒绝。
- 在浏览器页面打开此 URL。登录需要 Google OAuth 已配置。