use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java-intl-en by TencentCloud.
the class CommonClientRequest method main.
public static void main(String[] args) {
try {
Credential cred = new Credential("secretId", "secretKey");
CommonClient client = new CommonClient("cvm", "2017-03-12", cred, "ap-guangzhou");
DescribeInstancesRequest req = new DescribeInstancesRequest();
String resp = client.commonRequest(req, "DescribeInstances");
System.out.println(resp);
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java-intl-en by TencentCloud.
the class DescribeInstances method main.
public static void main(String[] args) {
try {
Credential cred = new Credential("your-secret-id", "your-secret-key");
HttpProfile httpProfile = new HttpProfile();
httpProfile.setReqMethod("GET");
httpProfile.setConnTimeout(30);
httpProfile.setEndpoint("cvm.ap-shanghai.tencentcloudapi.com");
ClientProfile clientProfile = new ClientProfile();
clientProfile.setSignMethod("HmacSHA256");
clientProfile.setHttpProfile(httpProfile);
CvmClient client = new CvmClient(cred, "ap-shanghai", clientProfile);
DescribeInstancesRequest req = new DescribeInstancesRequest();
Filter respFilter = new Filter();
respFilter.setName("zone");
respFilter.setValues(new String[] { "ap-shanghai-1", "ap-shanghai-2" });
req.setFilters(new Filter[] { respFilter });
DescribeInstancesResponse resp = client.DescribeInstances(req);
System.out.println(DescribeInstancesResponse.toJsonString(resp));
System.out.println(resp.getTotalCount());
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
use of com.tencentcloudapi.common.Credential in project tencentcloud-sdk-java-intl-en by TencentCloud.
the class DescribeZones method main.
public static void main(String[] args) {
try {
Credential cred = new Credential("secretId", "secretKey");
CvmClient client = new CvmClient(cred, "ap-guangzhou");
DescribeZonesRequest req = new DescribeZonesRequest();
DescribeZonesResponse resp = client.DescribeZones(req);
System.out.println(DescribeZonesRequest.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
use of com.tencentcloudapi.common.Credential in project MaxKey by dromara.
the class SmsOtpAuthnTencentCloud method produce.
@Override
public boolean produce(UserInfo userInfo) {
// 手机号
String mobile = userInfo.getMobile();
if (mobile != null && !mobile.equals("")) {
try {
Credential cred = new Credential(secretId, secretKey);
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("sms.tencentcloudapi.com");
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile);
String token = this.genToken(userInfo);
String params = "{\"PhoneNumberSet\":[\"" + mobile + "\"]," + "\"TemplateID\":\"" + templateId + "\",\"Sign\":\"" + sign + "\"," + "\"TemplateParamSet\":[\"" + token + "\",\"" + this.interval + "\"]," + "\"SmsSdkAppid\":\"" + smsSdkAppid + "\"}";
SendSmsRequest req = SendSmsRequest.fromJsonString(params, SendSmsRequest.class);
SendSmsResponse resp = client.SendSms(req);
logger.debug("responseString " + SendSmsRequest.toJsonString(resp));
if (resp.getSendStatusSet()[0].getCode().equalsIgnoreCase("Ok")) {
this.optTokenStore.store(userInfo, token, userInfo.getMobile(), OtpTypes.SMS);
return true;
}
} catch (Exception e) {
logger.error(" produce code error ", e);
}
}
return false;
}
use of com.tencentcloudapi.common.Credential in project cloud-sdk by mizhousoft.
the class SensitiveWordsRecognitionServiceImpl method init.
public void init(NLPProfile profile) throws CloudSDKException {
NLPProfileValidator.validate(profile);
Credential cred = new Credential(profile.getAccessKey(), profile.getSecretKey());
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint(profile.getEndpoint());
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
NlpClient client = new NlpClient(cred, profile.getRegion(), clientProfile);
this.nlpClient = client;
LOG.info("Init nlp client successfully.");
}
Aggregations