帮助与文档

> >
다운로드

一键登录服务端接入文档

接口文档

HOST地址

http://identify.verify.mob.com

接口地址

/auth/auth/sdkClientFreeLogin

请求方式

POST
header:application/json

请求参数

字段 类型 说明 必传
appkey String app标识 Y
token String 客户端的token Y
opToken String 客户端返回的运营商token Y
operator String 客户端返回的运营商,CMCC:中国移动通信, CUCC:中国联通通讯, CTCC:中国电信 Y
phoneOperator String 手机4G运营商 CMCC:中国移动通信, CUCC:中国联通通讯, CTCC:中国电信 N
sign String 签名(MD5(所有参数使用key的正序,通过a=b&b=c+appSecret组成)) Y
timestamp long 当前时间戳(毫秒) Y
md5 String android必须要填写,例:e4caa1a08ba0570b5c1290b1a0bc9252 N

请求明文

{"opMsg": "", "token": "mytoken", "appkey": "appkey", "operator": "", "tag": "", "sign": "", "timestamp": 12312312312}

返回明文

返回的密文

{"error":null,"res":"QArCscmzM94A4Ey+unhgEQBaBGAPtN66KTxG8ckTgr4fiH1jDGV8jpbIV5GPjupQFDjoWdaoPrs=","status":200}

res解密之后

{
    "isValid":1, 
    "phone": "13888888888",
    "nickName": "",
    "openId":"",
    "userIconUrl":"",
    "userIconUrl2":"",
    "userIconUrl3":"",
    "email":"",
    "operator":""
}
字段 类型 必传 说明
isValid integer Y 验证状态,1:成功, 2:失败
phone string Y 返回手机号
nickName string N 用户昵称
openId string N 用户在该应用下统一标识,可以唯一标识一个用户
userIconUrl string N 用户头像链接尺寸(大)160X160
userIconUrl2 string N 用户头像链接尺寸(中)100*100
userIconUrl3 string N 用户头像链接尺寸(小)50X50
email string N 用户绑定天翼账号的电子邮箱
operator string N 手机号码所属运营商:“中国电信”、“中国移动”、“中国联通”

加密方式

返回的数据需要使用appSecet解密

返回的数据使用加密方式

DES/CBC/PKCS5Padding 偏移量 00000000 使用base64转码

签名方法

public class SignUtil {
    private static String charset = "utf8";

    public static String getSign(Map<String, Object> data, String secret) {
        if (data == null) {
            return null;
        }
        //排序参数
        Map<String, Object> mappingList = new TreeMap<>(data);
        StringBuilder plainText= new StringBuilder();
        mappingList.forEach((k, v) -> {
            if (!"sign".equals(k) && !BaseUtils.isEmpty(v)) {
                plainText.append(String.format("%s=%s&", k, v));
            }
        });
        String substring = plainText.substring(0, plainText.length() - 1);
        return Md5Util.MD5Encode(substring + secret, charset);
    }
}

webapi 调用示例

public static void main(String[] arg) {
    String url = authHost + "auth/auth/sdkClientFreeLogin";
    HashMap<String, Object> request = new HashMap<>();
    request.put("appkey", appkey);
    request.put("token", token);
    request.put("opToken", opToken);
    request.put("operator", "CMCC");
    request.put("timestamp", System.currentTimeMillis());
    request.put("sign", SignUtil.getSign(request, appSecret));
    String response = postRequestNoSecurity(url, null, request);

    JSONObject jsonObject = JSONObject.parseObject(response);
    if (200 == jsonObject.getInteger("status")) {
        String res = jsonObject.getString("res");
        byte[] decode = DES.decode(Base64Utils.decode(res.getBytes()), appSecret.getBytes());
        jsonObject.put("res", JSONObject.parseObject(new String(decode)));
    }
    return jsonObject;
}

public static String postRequestNoSecurity(String url, Map<String, String> headers, Object data) throws Exception {
    String securityReq = JSON.toJSONString(data);
    OkHttpClient okHttpClient = new OkHttpClient.Builder().readTimeout(30, TimeUnit.SECONDS).build();
    RequestBody body = RequestBody.create(MediaType.parse("application/json"), securityReq);
    Request.Builder builder = new Request.Builder();
    if (!BaseUtils.isEmpty(headers)) {
        for (Map.Entry<String, String> entry : headers.entrySet()) {
            builder.addHeader(entry.getKey(), entry.getValue());
        }
    }
    final Request request = builder.addHeader("Content-Length", String.valueOf(securityReq.length()))
            .url(url)
            .post(body)
            .build();
    Call call = okHttpClient.newCall(request);
    Response response = call.execute();

    String securityRes = response.body().string();
    return securityRes;
}

DES加密类

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
import java.security.Key;
import java.security.spec.AlgorithmParameterSpec;

public class DES {

    public static final String ALGORITHM = "DES";
    public static final String PADDING = "DES/CBC/PKCS5Padding";
    private static final byte[] DEFAULT_INITIALIZATION_VECTOR = ("00000000".getBytes()) ;

    private String padding = PADDING;
    private byte[] initializationVectorBytes = DEFAULT_INITIALIZATION_VECTOR;
    private AlgorithmParameterSpec paramSpec;
    public DES(){
        this.paramSpec = new IvParameterSpec(initializationVectorBytes);
    }

    public DES(String padding) {
        this.padding = padding;
        this.paramSpec = new IvParameterSpec(initializationVectorBytes);
    }

    public DES(String padding, byte[] initializationVectorBytes) {
        this.padding = padding;
        this.initializationVectorBytes = initializationVectorBytes;
        this.paramSpec = new IvParameterSpec(initializationVectorBytes);
    }

    public DES(byte[] initializationVectorBytes) {
        this.initializationVectorBytes = initializationVectorBytes;
        this.paramSpec = new IvParameterSpec(initializationVectorBytes);
    }

    public byte[] encodeBytes(byte[] data,byte[] key) throws Exception {
        Key secretKey = getKey(key);
        Cipher cipher = Cipher.getInstance(padding);
        cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec);
        byte[] bytes = cipher.doFinal(data);
        return bytes;
    }

    public byte[] decodeBytes(byte[] data,byte[] key) throws Exception {
        Key secretKey = getKey(key);
        Cipher cipher = Cipher.getInstance(padding);
        cipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec);
        return cipher.doFinal(data);

    }

    public String getPadding() {
        return padding;
    }

    public byte[] getInitializationVectorBytes() {
        return initializationVectorBytes;
    }

    private static Key getKey(byte[] key) throws Exception {
        DESKeySpec dks = new DESKeySpec(key);
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
        SecretKey secretKey = keyFactory.generateSecret(dks);
        return secretKey;
    }

    public static byte[] decode(byte[] data, byte[] key) throws Exception {
        return decode(data,key,DEFAULT_INITIALIZATION_VECTOR);
    }

    public static byte[] encode(byte[] data, byte[] key) throws Exception {
        return encode(data,key,DEFAULT_INITIALIZATION_VECTOR);
    }

    public static byte[] decode(byte[] data, byte[] key, byte[] ivBytes) throws Exception {
        DES des = new DES(PADDING,ivBytes);
        return des.decodeBytes(data,key);
    }

    public static byte[] encode(byte[] data, byte[] key, byte[] ivBytes) throws Exception {
        DES des = new DES(PADDING,ivBytes);
        return des.encodeBytes(data,key);
    }
}

 

 

 

错误返回码

错误码 说明
5119104 解密失败
5119105 服务错误
4119301 数据校验失败
4119302 数据不存在
5119302 数据不存在
4119303 数据已经存在
5119303 数据已经存在
4119310 token未找到
5119310 token未找到
4119311 token非法
4119330 App没有初始化
4119331 AppSecret错误
5119341 余额不足
5119501 未知的运营商类型
5119511 appkey每分钟验证次数超过限制
5119513 未审核的包名每天验证数量超过限制
4119521 包名没有配置
5119531 appkey在黑名单中
5119546 [免密登录][APP每分钟]超限
5119507 免密登录失败
5119509 免密获取TOKEN失败
4119342 签名错误
4119343 timestamp错误
5119601 未设置价格
벨 영화 역전검사 2 다운로드 wget https download 다운로드

相关文档