This commit is contained in:
张良(004796)
2024-04-29 10:58:45 +08:00
parent fa7541356e
commit 6669ab0414
7 changed files with 244 additions and 2 deletions

View File

@@ -19,6 +19,10 @@ import java.util.Objects;
@Slf4j
public class TencentAuthClient {
private final static String SECRET_ID = "AKIDviL2b1KWHGNdR6gLwLbfaHpBSVQ8i8Pe";
private final static String SECRET_KEY = "DapskQxS7gBXlsqgP0a0KXXK8oy45INf";
public static boolean faceDetectIsPass(String bizToken) {
GetDetectInfoEnhancedResponse resp = getDetectInfo(bizToken);
if (!Objects.isNull(resp)) {
@@ -37,7 +41,7 @@ public class TencentAuthClient {
public static GetDetectInfoEnhancedResponse getDetectInfo(String bizToken) {
GetDetectInfoEnhancedResponse resp = null;
try {
Credential cred = new Credential("AKIDviL2b1KWHGNdR6gLwLbfaHpBSVQ8i8Pe", "DapskQxS7gBXlsqgP0a0KXXK8oy45INf");
Credential cred = new Credential(SECRET_ID, SECRET_KEY);
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("faceid.tencentcloudapi.com");
httpProfile.setConnTimeout(10); // 请求连接超时时间,单位为秒(默认60秒)
@@ -62,10 +66,13 @@ public class TencentAuthClient {
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露并威胁账号下所有资源的安全性。以下代码示例仅供参考建议采用更安全的方式来使用密钥请参见https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential("AKIDviL2b1KWHGNdR6gLwLbfaHpBSVQ8i8Pe", "DapskQxS7gBXlsqgP0a0KXXK8oy45INf");
Credential cred = new Credential(SECRET_ID, SECRET_KEY);
// 实例化一个http选项可选的没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("faceid.tencentcloudapi.com");
httpProfile.setConnTimeout(10); // 请求连接超时时间,单位为秒(默认60秒)
httpProfile.setWriteTimeout(10); // 设置写入超时时间,单位为秒(默认0秒)
httpProfile.setReadTimeout(10);
// 实例化一个client选项可选的没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);