跳转至

自定义网页登录实现

This guide explains how to implement web login directly using the Hive server API instead of the web login page provided by Hive Platform. Refer to this document when the app needs its own login UI and direct IdP authentication handling.

Note

To use the custom web login API, app registration and OAuth 2.0 Access Token issuance must be completed in Hive Console.

Overview

Use custom web login in the following cases.

  • When you want to apply an app-specific login UI/UX
  • When you want to implement a login screen consistent with the existing website design
  • When you want to process login within your own page without redirecting to the web login page
API Endpoint 说明
POST /v2/game/auth/signinidp IdP sign-in
POST /v2/game/auth/connect IdP linking
POST /v2/game/auth/disconnect IdP unlinking
POST /v2/game/player/delete-project Delete account


IdP sign-in

Creates a new player with IdP information or returns existing player information if the IdP is already registered. When sign-in succeeds, check the PlayerID in data.player_id.

Warning

自定义网页登录 API 不支持创建访客(GUEST, idp_index: 0)账号。

Note

To use the Delete account API, set require_token to true to receive the Authorization value in the response header. If you do not use account deletion, set it to false.

请求 URL

生产 URL https://auth.qpyou.cn/v2/game/auth/signinidp
沙盒 URL https://sandbox-auth.qpyou.cn/v2/game/auth/signinidp
HTTP 方法 POST
Content-Type application/json
数据格式 JSON

请求头

字段名称 说明 类型 必填
X-Access-Token 用于应用服务器认证的 OAuth 2.0 Access Token
(请参阅 发行 OAuth Token
String Y
ISCRYPT 数据是否加密(0 = 不加密)(必须传递 0) Integer Y

请求正文

字段名称 说明 类型 必填
appid App ID String Y
idp_index IdP index code (IdP list) Integer Y
idp_user_id Unique IdP user identifier String Y
require_token Whether to request a player token. true when using Delete account, otherwise false Boolean Y

请求示例

{"appid":"com.com2us.hivesdk.normal.freefull.apple.global.ios.universal","idp_index":3,"idp_user_id":"google_67890","require_token":true}

Response header

字段名称 说明 类型
Authorization Session token. Used when calling Delete account API String

响应正文

字段名称 说明 类型
result_code 响应代码 Details Integer
result_msg 结果消息 String
token_validation JWT 验证结果(JWT 验证错误 Object
token_validation.result_code JWT 验证结果代码 Integer
token_validation.result_msg JWT 验证结果消息 String
data 结果数据 Object
data.player_id Player ID Integer
data.idp_index IdP index Integer
data.idp_id IdP name String
data.idp_user_id IdP user ID String

响应代码

Code value 说明
0 成功
2499 JWT 验证失败(请参阅 token_validation)
4200 IdP does not exist
5000 Internal server error


IdP linking

Links a new IdP to an existing player account. You must call this API after signing in with the IdP sign-in API.

请求 URL

生产 URL https://auth.qpyou.cn/v2/game/auth/connect
沙盒 URL https://sandbox-auth.qpyou.cn/v2/game/auth/connect
HTTP 方法 POST
Content-Type application/json
数据格式 JSON

请求头

字段名称 说明 类型 必填
X-Access-Token 用于应用服务器认证的 OAuth 2.0 Access Token
(请参阅 发行 OAuth Token
String Y
ISCRYPT 数据是否加密(0 = 不加密)(必须传递 0) Integer Y

请求正文

字段名称 说明 类型 必填
appid App ID String Y
idp_index IdP index code (IdP list) Integer Y
idp_user_id Unique IdP user identifier String Y
player_id Player ID to link Integer Y

请求示例

{"appid":"com.com2us.hivesdk.normal.freefull.apple.global.ios.universal","idp_index":2,"idp_user_id":"fb_12345678","player_id":100000001}

响应正文

字段名称 说明 类型
result_code 响应代码 Details Integer
result_msg 结果消息 String
token_validation JWT 验证结果(JWT 验证错误 Object
token_validation.result_code JWT 验证结果代码 Integer
token_validation.result_msg JWT 验证结果消息 String
data 结果数据 Object
data.player_id Player ID Integer
data.idp_index Linked IdP index Integer
data.idp_id Linked IdP name String
data.idp_user_id IdP user ID String

响应代码

Code value 说明
0 成功
1002 The IdP is already linked to another player
1003 The same IdP type is already linked
2002 Player does not exist
2499 JWT 验证失败(请参阅 token_validation)
4200 IdP does not exist
5000 Internal server error


IdP unlinking

Unlinks an IdP from a player account. You must call this API after signing in with the IdP sign-in API.

请求 URL

生产 URL https://auth.qpyou.cn/v2/game/auth/disconnect
沙盒 URL https://sandbox-auth.qpyou.cn/v2/game/auth/disconnect
HTTP 方法 POST
Content-Type application/json
数据格式 JSON

请求头

字段名称 说明 类型 必填
X-Access-Token 用于应用服务器认证的 OAuth 2.0 Access Token
(请参阅 发行 OAuth Token
String Y
ISCRYPT 数据是否加密(0 = 不加密)(必须传递 0) Integer Y

请求正文

字段名称 说明 类型 必填
appid App ID String Y
idp_index IdP index code (IdP list) Integer Y
idp_user_id Unique IdP user identifier String Y
player_id Player ID Integer Y

响应正文

字段名称 说明 类型
result_code 响应代码 Details Integer
result_msg 结果消息 String
token_validation JWT 验证结果(JWT 验证错误 Object
token_validation.result_code JWT 验证结果代码 Integer
token_validation.result_msg JWT 验证结果消息 String

响应代码

Code value 说明
0 成功
2499 JWT 验证失败(请参阅 token_validation)
4006 Linked IdP information does not exist
4200 IdP does not exist
5000 Internal server error
7000 Invalid token


Delete account

Deletes a player account. You must call this API after signing in with the IdP sign-in API.

  1. Set require_token to true when calling the IdP sign-in API.
  2. Store the Authorization value returned in the response header.
  3. Include the stored Authorization value in the request header when calling this API.
Warning

Account deletion cannot be undone. Provide sufficient notice to the user before deletion.

请求 URL

生产 URL https://auth.qpyou.cn/v2/game/player/delete-project
沙盒 URL https://sandbox-auth.qpyou.cn/v2/game/player/delete-project
HTTP 方法 POST
Content-Type application/json
数据格式 JSON

请求头

字段名称 说明 类型 必填
X-Access-Token 用于应用服务器认证的 OAuth 2.0 Access Token
(请参阅 发行 OAuth Token
String Y
ISCRYPT 数据是否加密(0 = 不加密)(必须传递 0) Integer Y
Authorization Session token received in the response header after calling IdP sign-in with require_token: true String Y

请求正文

字段名称 说明 类型 必填
appid App ID String Y
player_id Player ID to delete Integer Y
did Device ID. Fixed to 0 Integer Y

响应代码

Code value 说明
0 成功
2499 JWT 验证失败(请参阅 token_validation)
5000 Internal server error
7000 Invalid token
7001 No token in header
Note

JWT 验证失败时,可在 token_validation 字段中查看详细错误信息。详情请参阅 JWT 验证错误代码