万网中台
征信查询接口文档
预审相关接口文档
接口认证
企业微信接口文档
渠道商回调接口文档
凭证中台对接文档
本文档使用 MrDoc 发布
-
+
首页
接口认证
# 接口描述 * 使用OAuth2的客户端认证方式 * token有效期参考响应参数 `expires_in` * 后续接口使用需传递header `Authorization : <token_type> <access_token>` # 请求地址 POST /auth/oauth2/token # 请求参数 | 参数名 | 类型 | 必填 | 参数位置| 描述 | | --- | --- | --- | ---| --- | | grant_type |string|是|`form` |固定为`client_credentials`| |Authorization | base64 | 是 |header |需将client_id与client_secret用":"拼接进行base64编码 `Basic <toBase64(client_id:client_secret)>`| # 响应参数 | 参数名 | 类型 | 描述 | | --- | --- | --- | | access_token | string | 用于后续接口请求的token | | token_type | string | token类型,固定为Bearer | | expires_in | int | token有效期(秒) | # 请求示例 ```http POST /auth/oauth2/token # 请求头: Authorization: Basic <toBase64(client_id:client_secret)> # form参数: grant_type=client_credentials ``` # 响应示例 ```json { "access_token": "5c507e32-7e81-4a64-a3e6-09420b6c1396" , "token_type": "Bearer", "expires_in" : 43199 } ``` # 代码示例 ```Java import cn.hutool.http.HttpRequest; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; /** * @author gzs * @description: 获取认证token * @date 2025/10/29 15:03 */ public class AuthTokenExample { private static final String AUTH_URL = "http://172.16.10.5:49999/auth/oauth2/token"; private static final String CLIENT_ID = "xxx"; private static final String CLIENT_SECRET = "xxxxx"; public static void main(String[] args) { // 获取token String authResponseStr = HttpRequest.post(AUTH_URL) .basicAuth(CLIENT_ID, CLIENT_SECRET) .form("grant_type", "client_credentials")// 固定值,客户端授权模式 .execute() .body(); System.out.println(JSONUtil.toJsonPrettyStr(authResponseStr)); JSONObject resJson = JSONUtil.parseObj(authResponseStr); String token = resJson.getStr("token_type") + " " + resJson.getStr("access_token"); System.out.println(token); } } ``` # Apifox示例 
admin
2026年1月14日 13:32
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
PDF文档(打印)
分享
链接
类型
密码
更新密码