IdP 账号管理
使用 IdP(身份提供商)凭证信息创建和管理玩家帐户。 “IdP 帐户管理”API 通过服务器到服务器通信进行操作,其中应用程序服务器直接调用 Hive 身份验证服务器。它可用于多种用途,包括玩家 ID 创建、登录、IdP 链接和取消链接、在 Web 环境中实现登录以及迁移现有帐户。
Note
此 API 不支持通过 Google、Meta 和 Apple 等外部身份验证提供商进行用户身份验证或凭证获取。直接在应用程序客户端中实现这些过程,并将结果传递到应用程序服务器。
“IdP账户管理”功能提供的API如下。 | API 端点 | 描述 | | --- | --- | | POST /v2/game/auth/signinidp | IdP 登录 | | POST /v2/game/auth/connect | 关联 IdP | | POST /v2/game/auth/disconnect | 解除 IdP 关联 |
IdP 登录
使用 IdP 信息为新玩家创建玩家 ID,或者如果 IdP 已注册,则返回现有玩家信息。当IdP登录请求成功后,您可以在data.player_id中查看生成的玩家ID。
请求网址
请求头
| 字段名称 | 描述 | 类型 | 必填 |
| X-Access-Token | 用于应用程序服务器身份验证的 OAuth 2.0 访问令牌 (参见 OAuth 令牌签发) | String | Y |
| ISCRYPT | 数据是否加密(0 = 未加密;始终传递 0) | Integer | Y |
请求正文
| 字段名称 | 描述 | 类型 | 必填 |
| appid | 应用程序 ID | String | Y |
| idp_index | IdP 索引代码。参见 IdP 索引参考 | Integer | Y |
| idp_user_id | IdP 用户唯一标识符 | String | Y |
| require_token | 是否请求玩家令牌。使用 账号删除 API 时的 true; false 不使用时 | Boolean | Y |
Note
要使用 账号删除 API,请将 require_token 设置为 true 以接收响应标头中的 Authorization 值。如果您不使用帐户删除功能,请将其设置为false。
响应头
| 字段名称 | 描述 | 类型 |
| Authorization | 会话令牌。仅当 require_token: true 时签发 | String |
| Content-Type | 响应数据格式(JSON)及字符编码(UTF-8)信息 | String |
| ISCRYPT | 响应是否加密 | Integer |
响应正文
| 字段名称 | 描述 | 类型 |
| result_code | 响应代码 详情 | Integer |
| result_msg | 结果留言 | String |
| token_validation | JWT 验证结果 (JWT 验证错误) | Object |
| token_validation.result_code | JWT验证结果码 | Integer |
| token_validation.result_msg | JWT 验证结果消息 | String |
| data.player_id | PlayerID | BigInteger |
| data.idp_index | IdP 指数 | Integer |
| data.idp_id | IdP 名称 | String |
| data.idp_user_id | IdP 用户 ID | String |
响应代码
| 代码值 | 描述 |
| 0 | 成功 |
| 2499 | JWT 验证失败(请参阅 token_validation) |
| 4000 | 无效参数 |
| 4001 | 请求 JSON 错误 |
| 4200 | 不存在的 IdP |
| 5000 | 内部服务器错误 |
| 7000 | 无效令牌 |
| 7001 | 标头中没有标记值 |
请求示例
{
"appid": "com.com2us.hivesdk.normal.freefull.apple.global.ios.universal",
"idp_index": 3,
"idp_user_id": "google_67890",
"require_token": true
}
响应示例
标题
HTTP/1.1 200
Content-Type: application/json; charset=UTF-8
Authorization: abcdf7ebce779429ea878f91d5f1c8
ISCRYPT: 0
成功
{
"result_code": 0,
"result_msg": "SUCCESS",
"token_validation": {
"result_code": 0,
"result_msg": "success"
},
"data": {
"player_id": 100000002,
"idp_index": 3,
"idp_id": "GOOGLE",
"idp_user_id": "google_67890"
}
}
链接 IdP
将新的 IdP 链接到现有玩家帐户。仅在创建玩家 ID 后,IdP 链接才可用。
请求网址
请求头
| 字段名称 | 描述 | 类型 | 必填 |
| X-Access-Token | 用于应用程序服务器身份验证的 OAuth 2.0 访问令牌 (参见 OAuth 令牌签发) | String | Y |
| ISCRYPT | 数据是否加密(0 = 未加密;始终传递 0) | Integer | Y |
请求正文
| 字段名称 | 描述 | 类型 | 必填 |
| appid | 应用程序 ID | String | Y |
| idp_index | IdP 索引代码。参见 IdP 索引参考 | Integer | Y |
| idp_user_id | IdP 用户唯一标识符 | String | Y |
| player_id | PlayerID 链接 | BigInteger | Y |
响应正文
| 字段名称 | 描述 | 类型 |
| result_code | 响应代码 详情 | Integer |
| result_msg | 结果留言 | String |
| token_validation | JWT 验证结果 (JWT 验证错误) | Object |
| token_validation.result_code | JWT验证结果码 | Integer |
| token_validation.result_msg | JWT 验证结果消息 | String |
| data.player_id | PlayerID | BigInteger |
| data.idp_index | 链接 IdP 索引 | Integer |
| data.idp_id | 链接的 IdP 名称 | String |
| data.idp_user_id | IdP 用户 ID | String |
| #### 响应代码 | | |
| 代码值 | 描述 | |
| --- | --- | |
| 0 | 成功 | |
| 1002 | 此 IdP 已链接到另一个玩家 | |
| 1003 | 相同的 IdP 类型已链接 | |
| 2002 | 不存在的玩家 | |
| 2499 | JWT 验证失败(请参阅 token_validation) | |
| 4000 | 无效参数 | |
| 4200 | 不存在的 IdP | |
| 5000 | 内部服务器错误 | |
| 7000 | 无效令牌 | |
| 7001 | 标头中没有标记值 | |
请求示例
{
"appid": "com.com2us.hivesdk.normal.freefull.apple.global.ios.universal",
"idp_index": 2,
"idp_user_id": "fb_12345678",
"player_id": 100000001
}
响应示例
成功
{
"result_code": 0,
"result_msg": "SUCCESS",
"token_validation": {
"result_code": 0,
"result_msg": "success"
},
"data": {
"player_id": 100000001,
"idp_index": 2,
"idp_id": "FACEBOOK",
"idp_user_id": "fb_12345678"
}
}
已链接至其他玩家
{
"result_code": 1002,
"result_msg": "Already connected other player",
"token_validation": {
"result_code": 0,
"result_msg": "success"
},
"data": {
"player_id": 100000002,
"idp_index": 2,
"idp_id": "FACEBOOK",
"idp_user_id": "fb_12345678"
}
}
取消链接 IdP
取消链接到玩家帐户的 IdP。仅在创建玩家 ID 后才可以使用 IdP 取消链接。
请求网址
请求头
| 字段名称 | 描述 | 类型 | 必填 |
| X-Access-Token | 用于应用程序服务器身份验证的 OAuth 2.0 访问令牌 (参见 OAuth 令牌签发) | String | Y |
| ISCRYPT | 数据是否加密(0 = 未加密;始终传递 0) | Integer | Y |
请求正文
| 字段名称 | 描述 | 类型 | 必填 |
| appid | 应用程序 ID | String | Y |
| idp_index | IdP 索引代码。参见 IdP 索引参考 | Integer | Y |
| idp_user_id | IdP 用户唯一标识符 | String | Y |
| player_id | PlayerID 取消链接 | BigInteger | Y |
响应正文
| 字段名称 | 描述 | 类型 |
| result_code | 响应代码 详情 | Integer |
| result_msg | 结果留言 | String |
| token_validation | JWT 验证结果 (JWT 验证错误) | Object |
| token_validation.result_code | JWT验证结果码 | Integer |
| token_validation.result_msg | JWT 验证结果消息 | String |
| #### 响应代码 | | |
| 代码值 | 描述 | |
| --- | --- | |
| 0 | 成功 | |
| 2499 | JWT 验证失败(请参阅 token_validation) | |
| 4000 | 无效参数 | |
| 4006 | 没有链接的 IdP 信息 | |
| 4200 | 不存在的 IdP | |
| 7000 | 无效令牌 | |
| 7001 | 标头中没有标记值 | |
请求示例
{
"appid": "com.com2us.hivesdk.normal.freefull.apple.global.ios.universal",
"idp_index": 2,
"idp_user_id": "fb_12345678",
"player_id": 100000001
}
响应示例
成功
{
"result_code": 0,
"result_msg": "SUCCESS",
"token_validation": {
"result_code": 0,
"result_msg": "success"
}
}
Note
当JWT验证失败时,您可以在token_validation字段中查看详细的错误信息。详细信息请参见JWT 验证错误代码。