令牌验证¶
使用从应用程序客户端成功登录后返回的 PlayerInfo 中的令牌、玩家 ID 和设备 ID 来验证应用程序服务器上的用户令牌。 验证令牌 API 通过服务器到服务器通信进行操作,其中应用程序服务器直接调用 Hive 身份验证服务器。如果应用程序不允许重复登录,您可以管理验证令牌或使用应用程序自己的会话密钥实施会话管理。
请求网址¶
| 生产网址 | https://auth.qpyou.cn/v2/game/token/get-token |
|---|---|
| 分布式环境URL | https://auth.globalwithhive.com/v2/game/token/get-token |
| 沙箱网址 | https://sandbox-auth.qpyou.cn/v2/game/token/get-token |
| HTTP 方法 | POST |
| Content-Type | application/json |
| 数据格式 | JSON |
Note
Hive认证服务器配置在分布式环境中,以应对故障或网络通信不稳定的情况。
如果与认证服务器主机通信失败,或者超过应用服务器定义的超时时间,应用服务器必须直接调用分布式环境URL(Fallback URL)。
请求头¶
| 字段名称 | 描述 | 类型 | 必填 |
|---|---|---|---|
| Authorization | 游戏客户端成功登录后返回的用户令牌(PlayerInfo.token) | String | Y |
| X-Access-Token | 游戏客户端登录成功后返回的用户Token OAuth 2.0 用于验证玩家身份的访问令牌 | String | Y |
| ISCRYPT | 数据是否加密(0 = 未加密;始终传递 0) | Integer | Y |
| ## 请求正文 | |||
| 字段名称 | 描述 | 类型 | 必填 |
| --- | --- | --- | --- |
| appid | 应用程序 ID | String | Y |
| did | 登录成功后返回的设备ID | String | Y |
| player_id | 登录成功后返回的验证玩家ID | BigInteger | Y |
| include_fields | 附加字段列表 用于在响应中请求附加信息的字段列表 | Array | N |
Note
您可以选择通过 include_fields 参数返回附加信息。当请求令牌验证时,响应根据 include_fields 数组中指定的字段值在 data 下包含相应的信息。
附加字段列表¶
| 字段名称 | 描述 | 类型 |
|---|---|---|
| is_blocked | 是否限制使用(true - 限制,false - 正常) | Boolean |
| is_device_registered | 是否使用设备管理(true - 使用,false - 不使用) | Boolean |
| join_timestamp | player_id 注册日期(Unix 时间戳) | Long |
| china_pi_no | 中国实名认证号码。未完成实名认证返回null | String / null |
| ## 响应体 | ||
| 字段名称 | 描述 | 类型 |
| --- | --- | --- |
| result_code | 响应代码, 0=验证成功 | Integer |
| result_msg | 结果留言 | String |
| token_validation | JWT 验证结果 (JWT 验证错误) | Object |
| token_validation.result_code | JWT验证结果码 | Integer |
| token_validation.result_msg | JWT 验证结果消息 | String |
| data | 包含请求中 include_fields 中指定信息的对象 | Object |
响应代码¶
| 代码值 | 描述 |
|---|---|
| 0 | 成功 |
| 2300 | 已退款用户需还款 |
| 4000 | 无效参数 |
| 4001 | 请求 JSON 错误 |
| 2499 | JWT 验证失败(请参阅 token_validation) |
| 5000 | 数据库错误 |
| 6000 | 无效的appid |
| 6001 | IdP 令牌错误 |
| 7000 | 无效令牌 |
| 7001 | 标头中没有标记值 |
| 9999 | 未知错误 |
| ## 请求示例 | |
包含字段¶
{
"appid": "com.com2us.hivesdk.normal.freefull.apple.global.ios.universal",
"did": "255764404509548",
"player_id": 10000000000,
"include_fields": ["is_blocked", "is_device_registered", "join_timestamp", "china_pi_no"]
}
响应示例¶
成功¶
{
"result_code": 0,
"result_msg": "SUCCESS",
"token_validation": {
"result_code": 0,
"result_msg": "success"
}
}
JWT 验证失败¶
{
"result_code": 2499,
"result_msg": "JWT validation failed. See token_validation for details.",
"token_validation": {
"result_code": 2408,
"result_msg": "The access token is expired. Please refresh your token."
}
}
包含字段¶
{
"result_code": 0,
"result_msg": "SUCCESS",
"token_validation": {
"result_code": 0,
"result_msg": "success"
},
"data": {
"is_blocked": false,
"is_device_registered": false,
"join_timestamp": 1495594605,
"china_pi_no": null
}
}
Note
当JWT验证失败时,您可以在token_validation字段中查看详细的错误信息。详细信息请参见JWT 验证错误代码。