平台简介
新手指南
API协议
API文档
单点登录集成
小程序插件
常见问题
开放平台API接口调用常见报错以及解决方法汇总
帮助中心 / 开放平台帮助文档 / 生成个人认证令牌
生成个人认证令牌
个人认证令牌生成

生成个人认证令牌

请求地址

/v2/personalauth/miniappexchange

请求方法

POST

请求格式

application/json;charset=UTF-8

请求参数

参数名称 类型 必须 描述
mode String 实名认证模式,IVS(三要素)、FACE(人脸认证)、ALIPAY(支付宝认证)、BANK(银行卡认证),默认为DEFAULT(不指定认证模式,默认使用可使用的所有认证)
user UserInfo 待认证用户信息
paperType String 证件类型,IDCARD(二代身份证),PASSPORT(护照),HKMP(港澳通行证),MTPS(台胞证),默认为IDCARD
username String 指定用户认证名称
idCardNo String 指定用户身份证号
bankNo String 指定用户银行卡号
bankMobile String 指定用户银行卡预留手机号
callbackUrl String 认证回调地址
otherModes List<String> 降级认证方式可选项(三要素-IVS,人脸认证-FACE,支付宝认证-ALIPAY,银行卡认证-BANK,人工审核-MANUAL)
modifyFields List<OpenAuthModifyField> 认证可修改项 (姓名-USERNAME,身份证-IDCARDNO,银行卡号-BANKNO,银行卡预留手机号-BANKMOBILE)

UserInfo :

名称 类型 必须 描述
contact String 联系方式
contactType String 联系方式类型:MOBILE、EMAIL

返回参数

名称 类型 描述
code Integer 响应码
message String 响应消息
result PersonAuthResponse 认证令牌信息

PersonAuthResponse:

名称 类型 描述
ticket String 令牌内容

请求示例

Http示例

POST /v2/personalauth/miniappexchange HTTP/1.1
Host: [host]
x-qys-open-timestamp: [替换为请求头生成的Timestamp]
x-qys-open-signature: [替换为请求头生成的Signature]
x-qys-open-accesstoken: [替换为请求头生成的Token]
Content-Type: application/json
{
    "mode":"BANK",
    "user":{
        "contact":"10020033044",
        "contactType":"MOBILE"
    },
    "username":"张三",
    "callbackUrl":"http://www.qiyuesuo.com"
}
Java示例

String serverUrl = "https://openapi.qiyuesuo.cn";
String accessKey = "替换为您申请的开放平台App Token";
String accessSecret = "替换为您申请的开放平台App Secret";
SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret);
UserAuthMiniappTicketRequest request = new UserAuthMiniappTicketRequest(new User("10020033044", "MOBILE"));
String response = null;
try {
    response = sdkClient.service(request);
} catch (Exception e) {
    throw new BaseSdkException("调用接口错误,错误原因:"+e.getMessage());
}
SdkResponse<MiniappTicketResult> result = JSONUtils.toQysResponse(response,MiniappTicketResult.class);
if(!result.getCode().equals(0)) {
    throw new BaseSdkException("获取个人认证Ticket失败,失败原因:"+result.getCode()+","+result.getMessage());
}
logger.info("获取个人认证Ticket成功,Ticket:"+result.getResult().getTicket());
C#示例

// 初始化sdkClient
string serverUrl = "https://openapi.qiyuesuo.cn";
string accessKey = "替换为您申请的开放平台App Token";
string accessSecret = "替换为您申请的开放平台App Secret";
SDKClient client = new SDKClient(accessKey, accessSecret, serverUrl);
UserAuthMiniappTicketRequest request = new UserAuthMiniappTicketRequest(new User("10020033044", "MOBILE"));
string response = null;
try
{
    response = client.Service(request);
}
catch (Exception e)
{
    throw new Exception("访问接口失败,失败原因:" + e.Message);
}
SdkResponse<MiniappTicketResult> responseObject = HttpJsonConvert.DeserializeResponse<MiniappTicketResult>(response);
if (!responseObject.Code.Equals(0))
{
    Console.WriteLine("获取个人认证Ticket失败,失败原因:" + responseObject.Code + "," + responseObject.Message);
}
else
{
    Console.WriteLine("获取个人认证Ticket成功,ticket:" + responseObject.Result.Ticket);
}
PHP示例

// 初始化$sdkClient
class Util {
    const     url = "https://openapi.qiyuesuo.cn";
    const     accessKey = "替换为您申请的开放平台App Token";
    const     accessSecret = "替换为您申请的开放平台App Secret";
}
$sdkClient = Util::getSDk();
$userAuthMiniappTicketRequest = new UserAuthMiniappTicketRequest();
// 待认证的用户信息
$user = new User();
$user->setContactType("MOBILE");
$user->setContact("10010002000");
$userAuthMiniappTicketRequest->setMode("DEFAULT");
$userAuthMiniappTicketRequest->setUser($user);
$userAuthMiniappTicketRequest->setUsername('自定义用户一号');
$userAuthMiniappTicketRequest->setIdCardNo('142732199404234835');
$modifyFields = array();
array_push($modifyFields,'USERNAME');
array_push($modifyFields,'IDCARDNO');
array_push($modifyFields,'MOBILE');
$userAuthMiniappTicketRequest->setModifyFields($modifyFields);
print_r($userAuthMiniappTicketRequest->getHttpParamers()->getJsonParams());
$result = $sdkClient->service($userAuthMiniappTicketRequest);
print_r($result);
return $result;
Python示例

# 初始化SdkClient
url = "https://openapi.qiyuesuo.cn"
accessToken = '替换为您申请的开放平台App Token'
accessSecret = '替换为您申请的开放平台App Secret'
sdkClient = SdkClient(url, accessToken, accessSecret)
request = UserAuthMiniappTicketRequest()
request.set_mode("DEFAULT")
modifyFields = []
modifyFields.append("USERNAME")
request.set_modifyFields(modifyFields)
request.set_paperType("IDCARD")
user = User()
user.set_contact("151****64046497")
user.set_contactType("MOBILE")
request.set_user(user)
response = sdkClient.request(request)
print(str(response))