package com.ks.app.utils;
|
|
import com.aliyuncs.DefaultAcsClient;
|
import com.aliyuncs.IAcsClient;
|
import com.aliyuncs.dypnsapi.model.v20170525.GetMobileRequest;
|
import com.aliyuncs.dypnsapi.model.v20170525.GetMobileResponse;
|
import com.aliyuncs.exceptions.ClientException;
|
import com.aliyuncs.exceptions.ServerException;
|
import com.aliyuncs.profile.DefaultProfile;
|
import com.google.gson.Gson;
|
import org.yeshi.utils.StringUtil;
|
|
/**
|
* @author hxh
|
* @title: AliyunOneKeyLoginUtil
|
* @description: 阿里云一键登录
|
* @date 2021/11/15 11:03
|
*/
|
public class AliyunOneKeyLoginUtil {
|
|
private final static String ACCESS_KEY = "LTAI4FwmTxVCuzTaoZtDiV8z";
|
private final static String ACESS_SCRET = "ixWg90QbYFKP6ae5xpAo2P1qwIyll5";
|
|
public static String getMobile(String accessToken, String outId,String acessKey,String acessSecret) {
|
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", acessKey, acessSecret);
|
IAcsClient client = new DefaultAcsClient(profile);
|
|
GetMobileRequest request = new GetMobileRequest();
|
request.setAccessToken(accessToken);
|
if (!StringUtil.isNullOrEmpty(outId))
|
request.setOutId(outId);
|
|
try {
|
GetMobileResponse response = client.getAcsResponse(request);
|
System.out.println(new Gson().toJson(response));
|
if (response.getGetMobileResultDTO() != null) {
|
String mobile = response.getGetMobileResultDTO().getMobile();
|
return mobile;
|
}
|
System.out.println(new Gson().toJson(response));
|
} catch (ServerException e) {
|
e.printStackTrace();
|
} catch (ClientException e) {
|
System.out.println("ErrCode:" + e.getErrCode());
|
System.out.println("ErrMsg:" + e.getErrMsg());
|
System.out.println("RequestId:" + e.getRequestId());
|
}
|
return null;
|
}
|
|
}
|