获取访问接口Token
<h3>1、请求URL</h3>
<pre><code class="language-html">http://ip地址:端口/api/cus/token/auth/getToken</code></pre>
<h3>2、请求方式</h3>
<pre><code class="language-html">post</code></pre>
<h3>3、内容格式</h3>
<pre><code class="language-html">application/json</code></pre>
<h3>4、参数说明</h3>
<h4>4.1 请求参数:</h4>
<table>
<thead>
<tr>
<th>参数名</th>
<th>必须</th>
<th>类型</th>
<th>说明</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>appid</td>
<td>是</td>
<td>String</td>
<td>应用id</td>
<td>请求头参数</td>
</tr>
<tr>
<td>sign</td>
<td>是</td>
<td>String</td>
<td>签名,参考4.2(有效期5分钟)</td>
<td>请求头参数</td>
</tr>
<tr>
<td>userType</td>
<td>否</td>
<td>String</td>
<td>用户属性,参考4.5</td>
<td>请求头参数</td>
</tr>
<tr>
<td>userContain</td>
<td>否</td>
<td>String</td>
<td>用户属性值,参考4.5</td>
<td>请求头参数</td>
</tr>
</tbody>
</table>
<ul>
<li>appid及sign为必填项,用于获取token信息;userType及userContain为选填项,用于获取加密的userId信息;</li>
</ul>
<h4>4.2 sign示例(JAVA)</h4>
<pre><code class="language-json">package weaver.demo;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
/**
* Sign生成示例
*
* @author: Weaver_Xm
*/
public class MainTest {
public static void main(String[] args) {
//应用标识-->>泛微提供
String appid = "weaverappid";
//应用密钥-->>泛微提供
String secret = "weaversecret";
//AES密钥-->>泛微提供
String key = "8fy6K39X6PIEEeOq";
//MD5加密对象:appid+secret,以冒号连接;
String md5Encrypt = SecureUtil.md5(appid + ":" + secret).toUpperCase();
//构建AES加密、加密模式ECB 补码方式:PKCS5Padding
AES aes = SecureUtil.aes(key.getBytes());
//生成签名:毫秒级时间戳+MD5加密串,以下划线连接;
String sign = aes.encryptHex(System.currentTimeMillis() + "_" + md5Encrypt);
System.out.println("sign ===>>>" + sign);
}
}
</code></pre>
<h4>4.3 postman示例</h4>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/ab7390832630068293d1b280b65f712c" alt="" /></p>
<h4>4.4 AES加密说明</h4>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=5b25756ef015a40c79d5f9ee778beb91" alt="" /></p>
<h4>4.5 userType及userContain参数说明</h4>
<ul>
<li>userType为用户属性,userContain为对应属性值;同时传入时,接口会自动匹配相应的人员,并返回加密后的userId值,用于调用某些需校验User权限的接口;</li>
</ul>
<table>
<thead>
<tr>
<th>userType值</th>
<th>userType描述</th>
<th>userContain示例</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>用户id</td>
<td>9</td>
</tr>
<tr>
<td>loginid</td>
<td>登录名</td>
<td>zhangs</td>
</tr>
<tr>
<td>workcode</td>
<td>工号</td>
<td>A001</td>
</tr>
<tr>
<td>idnum</td>
<td>身份证号</td>
<td>35xxx</td>
</tr>
<tr>
<td>email</td>
<td>邮箱</td>
<td>abc@126.com</td>
</tr>
<tr>
<td>outkey</td>
<td>外部主键</td>
<td>E94DE860-DA64-4DA7-868A-F6213824A61B</td>
</tr>
</tbody>
</table>
<h3>5、请求结果</h3>
<h4>5.1 返回成功示例</h4>
<pre><code class="language-json">{
"msg": "获取成功!",
"status": true,
"token": "fdca51c0-2225-4ad9-ac18-bd2b61408b99"
}</code></pre>
<h4>5.2 返回成功示例</h4>
<pre><code class="language-json">{
"msg": "获取成功!",
"userid": "VG2rUZb8wApeJ2ozp26LPc/a+KeAZDNCHAmi+SdlxsPQovEc4rl2VrS5NCQ75en7rf5S15ALB1fWIcGDZJ23JYkvzHNx0Ei8zXIukSx3bQ8UbDdGf+M3Klu2gAPJpek5K1DgtwE25C47YnulPjLJ91fQIPhsLZvPuNLnM1/LRTI6n+Kh3w1dfnRBrOgYWv5Xdk+W9+7zlWOLhV1LyxSWm/Hr8Kf8dK7KYHKN+gVlAaaFSBL4u7aN7/RiqMBnbbf7OZxqvd4IUhl+c/M4HOyOF/uEBMX/+3GQZK/k/m5xTARFbQVcvAtLfgybedr+W301qBmu42d5qBtgURh0owVlwg==",
"status": true,
"token": "a1be51e9-0d3d-42ad-be82-89c0ba82a929"
}</code></pre>
<h4>5.3 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "应用标识appid==>>weaverappid已被禁用,请联系管理员!!!",
"status": false
}</code></pre>
<h4>5.4 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "appid或sign参数值异常!!!",
"status": false
}</code></pre>
<h4>5.5 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "禁用重复签名获取token,请确认!!!",
"status": false
}</code></pre>
<h4>5.6 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "签名解密异常,请确认!!!",
"status": false
}</code></pre>
<h4>5.7 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "签名已过期,请确认!!!",
"status": false
}</code></pre>
<h4>5.8 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "userType或userContain参数值异常!!!",
"status": false
}</code></pre>
<h4>5.9 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "userType:id123 无效,请确认!!!",
"status": false
}</code></pre>
<h4>5.10 返回失败示例</h4>
<pre><code class="language-json">{
"msg": "userId解析异常,请确认!!!",
"status": false
}</code></pre>
<h4>5.11 返回参数说明</h4>
<table>
<thead>
<tr>
<th>参数名</th>
<th>类型</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>status</td>
<td>boolean</td>
<td>响应状态。true:成功,false:失败</td>
</tr>
<tr>
<td>msg</td>
<td>String</td>
<td>响应信息</td>
</tr>
<tr>
<td>token</td>
<td>String</td>
<td>token信息(默认30分钟内有效)</td>
</tr>
</tbody>
</table>