认证授权
凭证续约
1.接口说明
接口路径:/ac/openapi/v2/tokens/next
请求方式:POST
请求数据类型:application/json
接口描述:区域用户认证,携带旧token续约,认证成功后返回新token凭证
备注:token过期特定时间(24小时)后,不可以再续约,需要调用获取访问凭证接口重新获得token凭证
2.请求消息
请求参数 header
名称 | 类型 | 必填 | 描述 | 示例 |
---|---|---|---|---|
token | string | 是 | 接口凭证 | eyJhbGciOiJIUzI1N... |
3.请求示例
cURL请求示例
curl --location --request POST 'https://api01.xxx.com:65102/ac/openapi/v2/tokens/next' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODY5MDg1MDkyMzEiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.U7pZKgO_K6NuRwOWPxblDfgRpGeVxS-BYieOdLhGDK4'
Java请求示例
import okhttp3.*;
public class RenewTokenDemo {
public static final String TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODY5MDg1MDkyMzEiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.U7pZKgO_K6NuRwOWPxblDfgRpGeVxS-BYieOdLhGDK4";
public static final String URL = "https://api01.xxx.com:65102/ac/openapi/v2/tokens/next";
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url(URL)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("token", TOKEN)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
Python请求示例
import requests
import json
url = "https://api01.xxx.com:65102/ac/openapi/v2/tokens/next"
payload = {}
headers = {
'Content-Type': 'application/json',
'token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODY5MDg1MDkyMzEiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.U7pZKgO_K6NuRwOWPxblDfgRpGeVxS-BYieOdLhGDK4'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
4.响应消息
参数说明
名称 | 类型 | 描述 | 示例 |
---|---|---|---|
msg | string | 信息 | success |
code | string | 状态码 | 0 |
data | array | 区域信息列表 | |
token | string | 新生成的token | eyJhbGciOiJIUzI1N... |
返回示例
{
"msg": "success",
"code": "0",
"data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6Imhhb3dqIiwiYWNjb3VudFN0YXR1cyI6Ik93ZSIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2MzQxNzg5ODQ0OTgiLCJjbHVzdGVySWQiOiIxMTEyNiIsImludm9rZXIiOiIyd2VhZGdlcWEiLCJ1c2VyIjoiaGFvd2oifQ.LUOEH3_7GjbdizcRhdPSpUxkg0mza8XM6Bd3_5ZAa-I"
}
5.错误码
错误码 | 说明 |
---|---|
10001 | 内部错误 |
10003 | 参数不全 |
10004 | 参数无效 |
10008 | 权限不足 |
10009 | 没有权限访问接口 |
0 | 接口调用成功 |