Awesome Auth Admin

这里是 Auth Admin 服务的 API 使用说明(默认前缀 /api)。 所有接口均支持 CORS 预检(OPTIONS),业务请求使用 POST。

鉴权流程

  1. Google 使用 GIS 获取 ID Token;Apple 从 GET /api/apple-auth/start 开始标准 OAuth redirect。
  2. Google 调用 POST /api/google-auth;Apple 回跳后调用 POST /api/apple-auth/exchange。两者都换取同格式 JWT。
  3. 后续请求在 Header 中携带 Authorization: Bearer <token>。
  4. 使用 POST /api/refresh-token 刷新 token;使用 POST /api/verify-auth 检查 token 是否有效。

接口一览

POST /api/google-auth

使用 Google ID Token 换取服务端 JWT。

请求体:{ "credential": "..." }

curl -X POST http://localhost:5173/api/google-auth \
  -H 'Content-Type: application/json' \
  -d '{"credential":"<google-id-token>}"'

GET /api/apple-auth/start

验证 return URL 后跳转 Apple;Apple 会 form_post 到服务端 callback。

查询:?return=https%3A%2F%2Fwww.arealme.com%2F...

POST /api/apple-auth/exchange

消费回跳 fragment 中 90 秒有效的交换凭证,返回普通 aAuth JWT。

请求体:{ "code": "..." }

POST /api/verify-auth

验证当前 token 并返回解码后的 payload。

curl -X POST http://localhost:5173/api/verify-auth \
  -H 'Authorization: Bearer <token>'

POST /api/refresh-token

使用当前 token 的 payload 重新签发一个新 token。

curl -X POST http://localhost:5173/api/refresh-token \
  -H 'Authorization: Bearer <token>'

POST /api/store

按用户维度存储一个键值对(需要鉴权)。

请求体:{ "key": "xxx", "value": "yyy" }

curl -X POST http://localhost:5173/api/store \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"key":"theme","value":"dark"}'

POST /api/retrieve

按用户维度读取一个键对应的值(需要鉴权)。

请求体:{ "key": "xxx" }

curl -X POST http://localhost:5173/api/retrieve \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"key":"theme"}'

配置说明