更新用户个人识别码。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求语法
POST HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| QuickBIUserId |
string |
否 |
Quick BI 的 UserId |
sasdasasd |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
|||
| RequestId |
string |
请求 ID |
685072a0-1fd5-40ef-ae6b-cf94e79e718f |
| Result |
object |
AK 模型 |
{ "icode": "V2Yc/dMFWBwTKLNCNxgnN****z***5ARu", "icodeKey": "b6f3***32a62936", "type": 1 } |
| Type |
integer |
AK 类型,目前仅有 1,个人 AK |
1 |
| Icode |
string |
SK |
V2Yc/dMFWBwTKLNCNxgnN****z***5ARu |
| IcodeKey |
string |
AK |
b6f3***32a62936 |
| Success |
boolean |
是否请求成功。取值范围:
|
true |
sk 数据需要解密方可使用,如您未设置组织密钥,可联系 Quick BI 服务进行组织密钥的设置,需要提供您的 base64 编码的密钥。
解密代码 java 示例:
package com.example.demo.openapi;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class testddd {
public static final String KEY_ALGORITHM = "AES";
public static final String CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
/**
* 您的 base_64 密钥
*/
public static final String BASE_64 = "xxxx";
public static void main(String[] args) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
String decrypt = decrypt("iCode-api-return", BASE_64);
System.out.println(decrypt);
}
/**
* 解密接口返回的 {@code icode},还原出明文 SK。
*
* @param cipherIcode 接口返回的 {@code icode} 字段,Base64 编码的 AES 密文
* @param base64SecretKey 贵司提供给 QuickBI 的密钥,Base64 编码的 16/24/32 字节
* @return 明文 SK
* @throws IcodeDecryptException 密文或密钥不合法、密钥不匹配时抛出,异常信息中含排查建议
*/
public static String decrypt(String cipherIcode, String base64SecretKey) {
byte[] keyBytes;
try {
keyBytes = Base64.getDecoder().decode(normalize(base64SecretKey));
} catch (IllegalArgumentException e) {
throw new IcodeDecryptException("密钥不是合法的 Base64 字符串。请确认使用的是「Base64 编码后的密钥」,"
+ "而不是原始口令文本。", e);
}
byte[] cipherBytes;
try {
cipherBytes = Base64.getDecoder().decode(normalize(cipherIcode));
} catch (IllegalArgumentException e) {
throw new IcodeDecryptException("icode 不是合法的 Base64 字符串,请确认传入的是接口返回的原始 icode 字段。", e);
}
try {
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(keyBytes, KEY_ALGORITHM));
// SK 为 ASCII 可见字符,按 UTF-8 还原与服务端加密时的字符集一致
return new String(cipher.doFinal(cipherBytes), StandardCharsets.UTF_8);
} catch (GeneralSecurityException e) {
throw new IcodeDecryptException("解密失败,请检查密钥是否与加密时使用的一致,或密文是否被截断/篡改。", e);
}
}
/**
* Base64 归一化:去掉所有空白字符(部分网关/日志会在长串中插入换行),
* 并把 URL-safe 变体的 {@code -}、{@code _} 还原为标准 Base64 的 {@code +}、{@code /}
* (表单传输时 {@code +} 常被解码成空格,这里一并还原)。
*/
private static String normalize(String base64Text) {
if (base64Text == null) {
throw new IllegalArgumentException("Base64 内容不能为空");
}
StringBuilder sb = new StringBuilder(base64Text.length());
for (int i = 0; i < base64Text.length(); i++) {
char c = base64Text.charAt(i);
if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f') {
// 跳过空白;注意密文里的空格只可能来自 '+' 被表单解码,已由下面的分支处理
continue;
}
if (c == '-') {
sb.append('+');
} else if (c == '_') {
sb.append('/');
} else {
sb.append(c);
}
}
return sb.toString();
}
/**
* icode 解密过程中出现的异常。
*/
public static class IcodeDecryptException extends RuntimeException {
public IcodeDecryptException(String message) {
super(message);
}
public IcodeDecryptException(String message, Throwable cause) {
super(message, cause);
}
}
}
示例
正常返回示例
JSON格式
{
"RequestId": "685072a0-1fd5-40ef-ae6b-cf94e79e718f",
"Result": {
"Type": 1,
"Icode": "V2Yc/dMFWBwTKLNCNxgnN****z***5ARu",
"IcodeKey": "b6f3***32a62936"
},
"Success": true
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | Internal.System.Error | An internal system error occurred. | 系统内部异常。 |
| 400 | Invalid.Parameter.Error | The parameter is invalid:%s. | 无效参数%s。 |
| 400 | Invalid.User.Organization | The user is not in your organization. | 该用户不在您的组织中。 |
| 400 | UserInfo.Error | The personal information is invalid. | 个人信息不合法。 |
| 400 | PersonalIcode.NotExist.Error | Personal identification code not exist, please create it first: %s. | 个人识别码不存在,请先创建:%s。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。