forked from luyan/epmet-cloud-lingshan
3 changed files with 78 additions and 0 deletions
@ -0,0 +1,49 @@ |
|||
package com.epmet.commons.tools.utils.net; |
|||
|
|||
import com.tencentcloudapi.ccc.v20200210.CccClient; |
|||
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenRequest; |
|||
import com.tencentcloudapi.ccc.v20200210.models.CreateSDKLoginTokenResponse; |
|||
import com.tencentcloudapi.common.Credential; |
|||
import com.tencentcloudapi.common.exception.TencentCloudSDKException; |
|||
import com.tencentcloudapi.common.profile.ClientProfile; |
|||
import com.tencentcloudapi.common.profile.HttpProfile; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
|
|||
|
|||
@Slf4j |
|||
public class TCCCClientUtils { |
|||
|
|||
private static String SDKAPPID = "1400801042"; |
|||
|
|||
private static String USERID = "286388969@qq.com"; |
|||
|
|||
private static String SECRETID = "AKIDynW4oQr6ED0a2dIn6EC3wgFlDVjrqIbg"; |
|||
|
|||
private static String SECRETKEY = "ymRuDJI8mCRUUPFvQqCPQME0c2MbfaM2"; |
|||
|
|||
public static String getToken() { |
|||
try { |
|||
Credential cred = new Credential(SECRETID, SECRETKEY); |
|||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
|||
HttpProfile httpProfile = new HttpProfile(); |
|||
httpProfile.setEndpoint("ccc.ap-shanghai.tencentcloudapi.com"); |
|||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
|||
ClientProfile clientProfile = new ClientProfile(); |
|||
clientProfile.setHttpProfile(httpProfile); |
|||
// 实例化要请求产品的client对象,clientProfile是可选的
|
|||
CccClient client = new CccClient(cred, "", clientProfile); |
|||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
|||
CreateSDKLoginTokenRequest req = new CreateSDKLoginTokenRequest(); |
|||
req.setSdkAppId(1400801042L); |
|||
req.setSeatUserId("286388969@qq.com"); |
|||
// 返回的resp是一个CreateSDKLoginTokenResponse的实例,与请求对象对应
|
|||
CreateSDKLoginTokenResponse resp = client.CreateSDKLoginToken(req); |
|||
// 输出json格式的字符串回包
|
|||
System.out.println(CreateSDKLoginTokenResponse.toJsonString(resp)); |
|||
return CreateSDKLoginTokenResponse.toJsonString(resp); |
|||
} catch (TencentCloudSDKException e) { |
|||
log.error(e.toString()); |
|||
return e.toString(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.epmet.controller.tccc; |
|||
|
|||
import com.epmet.commons.tools.utils.net.TCCCClientUtils; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("tccc") |
|||
public class TCCCAuthController { |
|||
|
|||
@RequestMapping("getTcccAuth") |
|||
public String getTcccAuth() { |
|||
try { |
|||
String tcccAuth = TCCCClientUtils.getToken(); |
|||
System.out.println(tcccAuth); |
|||
return tcccAuth; |
|||
} catch (Exception e) { |
|||
log.error(e.toString()); |
|||
return e.toString(); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue