认证接口
<p>[TOC]</p>
<h5>简要描述</h5>
<ul>
<li>获取/刷新token接口
access_token有效期:8640秒
refresh_token有效期:86400秒</li>
</ul>
<h5>请求URL</h5>
<ul>
<li><code>https://10.101.5.3:443/admin-api/system/oauth2/token</code></li>
</ul>
<h5>请求方式</h5>
<ul>
<li>POST </li>
<li><strong>请求数据类型: x-www-form-urlencoded</strong></li>
</ul>
<h5>参数</h5>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">grant_type</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>授权类型 client_credentials/refresh_token</td>
</tr>
<tr>
<td style="text-align: left;">client_id</td>
<td style="text-align: left;">否</td>
<td style="text-align: left;">string</td>
<td>客户端id</td>
</tr>
<tr>
<td style="text-align: left;">client_secret</td>
<td style="text-align: left;">否</td>
<td style="text-align: left;">string</td>
<td>客户端密钥</td>
</tr>
<tr>
<td style="text-align: left;">refresh_token</td>
<td style="text-align: left;">否</td>
<td style="text-align: left;">String</td>
<td>客户端刷新token</td>
</tr>
</tbody>
</table>
<h5>请求示例</h5>
<p>获取token:</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数值</th>
</tr>
</thead>
<tbody>
<tr>
<td>client_id</td>
<td>nc63_program</td>
</tr>
<tr>
<td>client_secret</td>
<td>$2a$10$I8CuCKufLQsVpPM9ARiCVOwq0Y5EeZyxyDeg8jHdmQaarOQ1bYWRS</td>
</tr>
<tr>
<td>grant_type</td>
<td>client_credentials</td>
</tr>
</tbody>
</table>
<p>刷新token:</p>
<table>
<thead>
<tr>
<th>参数名称</th>
<th>参数值</th>
</tr>
</thead>
<tbody>
<tr>
<td>grant_type</td>
<td>refresh_token</td>
</tr>
<tr>
<td>refresh_token</td>
<td>登录认证接口返回的refresh_token</td>
</tr>
</tbody>
</table>
<h5>返回参数说明</h5>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">code</td>
<td style="text-align: left;">int</td>
<td>错误码</td>
</tr>
<tr>
<td style="text-align: left;">data</td>
<td style="text-align: left;">obj</td>
</tr>
<tr>
<td style="text-align: left;">msg</td>
<td style="text-align: left;">string</td>
<td>错误提示消息</td>
</tr>
</tbody>
</table>
<p>data对象内参数如下:</p>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">scope</td>
<td style="text-align: left;">string</td>
<td>授权范围,如果多个授权范围,使用空格分隔</td>
</tr>
<tr>
<td style="text-align: left;">access_token</td>
<td style="text-align: left;">string</td>
<td>访问令牌(有效期8640秒)</td>
</tr>
<tr>
<td style="text-align: left;">refresh_token</td>
<td style="text-align: left;">strin</td>
<td>刷新令牌(有效期86400秒)</td>
</tr>
<tr>
<td style="text-align: left;">token_type</td>
<td style="text-align: left;">string</td>
<td>令牌类型</td>
</tr>
<tr>
<td style="text-align: left;">expires_in</td>
<td style="text-align: left;">int</td>
<td>过期时间,单位:秒</td>
</tr>
</tbody>
</table>
<h5>返回示例</h5>
<p>获取token/刷新token成功示例:</p>
<pre><code>{
&quot;code&quot;: 0,
&quot;data&quot;: {
&quot;scope&quot;: &quot;rest:nc63:verificat rest:nc63:reverseVerificat&quot;,
&quot;access_token&quot;: &quot;f154ee7428404793a5d1aa958264038f&quot;,
&quot;refresh_token&quot;: &quot;5e8e4501e1fa46adbc1ee49879856ba1&quot;,
&quot;token_type&quot;: &quot;bearer&quot;,
&quot;expires_in&quot;: 8639
},
&quot;msg&quot;: &quot;操作成功&quot;
}</code></pre>
<p>获取token失败示例:</p>
<pre><code>{
&quot;code&quot;: 1002020006,
&quot;data&quot;: null,
&quot;msg&quot;: &quot;无效 client_secret: test&quot;
}</code></pre>
<p>刷新token失败示例:</p>
<pre><code>{
&quot;code&quot;: 400,
&quot;data&quot;: null,
&quot;msg&quot;: &quot;无效的刷新令牌&quot;
}</code></pre>
<h5>调用示例</h5>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=ceaab526bdbb73904c913920fd3de9ea&amp;file=file.png" alt="" /></p>