访问令牌是开发者使用接口的凭证,通过访问令牌开发者可以使用自身权限下的各种接口。
请求URL:https://api.wuhaneduyun.cn/apigateway/getAccessToken
请求方式:POST
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
appId |
是 | string | 应用ID |
timeStamp |
是 | string | 时间戳(毫秒) |
keyInfo |
是 | string | 对appid、appkey、Timestamp进行 sha1-hmac 运算,加密串为 APPID 和 APPKEY 及 Timestamp 字符串相连,以 APPKEY 为加密参数;PHP 使用的签名函数:hash_hmac,hash_algos 参数值为 sha1。详见下方签名工具类 |
{
"appId": "5736915E311EA64DEA**",
"keyInfo": "E4AA972000C1262169743C**",
"timeStamp": "1458282**"
}
| 序号 | 必选 | 参数名 | 类型 | 说明 |
|---|---|---|---|---|
| 1 | 是 | retCode |
String | 返回码 |
| 2 | 是 | retDesc |
String | 返回码描述 |
| 3 | 是 | tokenInfo |
Json对象 | 返回的 token 对象信息 |
| 3.1 | 是 | validTime |
String | 返回 token 有效期 |
| 3.2 | 否 | platformCode |
String | 所属平台编码 |
| 3.3 | 是 | account |
String | 返回码 |
| 3.4 | 是 | appId |
String | 应用ID |
| 3.5 | 是 | accessToken |
String | 访问凭证 |
| 3.6 | 是 | appName |
String | 应用名称 |
{
"tokenInfo": {
"validTime": "14670914**",
"platformCode": "",
"userId": "AP93**",
"appId": "5736915E311EA64DEA**",
"accessToken": "77b117c4069e4f74b2434**",
"appName": "**"
},
"retCode": "000000",
"retDesc": "获取Token成功。"
}
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class HmacSHA1Util {
public static String hmacSHA1(String data, String key) throws Exception {
SecretKeySpec localSecretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1");
Mac localMac = Mac.getInstance("HmacSHA1");
localMac.init(localSecretKeySpec);
localMac.update(data.getBytes("UTF-8"));
return parseByte2HexStr(localMac.doFinal()).trim();
}
private static String parseByte2HexStr(byte buf[]) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < buf.length; i++) {
String hex = Integer.toHexString(buf[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toLowerCase());
}
return sb.toString();
}
}