快速開始

本頁帶你跑完一次最小化的 API 呼叫流程:用 Google OAuth 登入取得 Token,然後查詢可用的獎勵列表。

Base URL

所有 endpoint 都掛在統一的 base URL 下:

https://api.poshentw.com

舊的 api.auth-hub.poshentw.comapi.reward-hub.poshentw.com 已於閉門期切換後廢棄,新版客戶端一律使用上面的 domain。


第 1 步:取得 Token

把 Google ID Token 與 game_id 送到 POST /login/google

Request

POST
/login/google
curl https://api.poshentw.com/login/google \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "id_token": "eyJhbGc...假.id.token...0XYZ",
    "game_id": 1,
    "game_player_id": "unity-player-12345"
  }'

回應裡的 data.token 就是後續 API 使用的 Bearer Token:

Response

{
  "data": {
    "user": {
      "id": 42,
      "email": "alice@example.com",
      "name": "Alice",
      "avatar_url": null
    },
    "token": "1|aBcDeFgHiJkLmNoPqRsTuVwXyZ..."
  }
}

第 2 步:用 Token 查詢獎勵

把上一步拿到的 token 放在 Authorization header 裡:

Request

GET
/rewards
curl https://api.poshentw.com/rewards \
  -H "Authorization: Bearer 1|aBcDeFgHiJkLmNoPqRsTuVwXyZ..."

回應:

Response

{
  "data": [
    { "id": 1, "code": "GOLD_100", "name": "金幣 100", "type": "金幣" },
    { "id": 2, "code": "GEM_10", "name": "寶石 10", "type": "寶石" }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 20,
    "total": 2
  }
}

接下來

Was this page helpful?