简要描述:
- APP获取token【登录接口】
接口版本:
版本号 | 制定人 | 制定日期 | 修订日期 |
---|---|---|---|
0.0.1 | 宋德美 | 2024-12-03 |
请求URL:
- /gw/auth/getToken
请求方式:
- POST
请求头:
参数名 | 是否必须 | 类型 | 说明 |
---|---|---|---|
Content-Type | 是 | string | 请求类型: application/json |
Token | 是 | string | 请求token,详见下方:token生成规则 |
请求参数:
参数名 | 是否必须 | 类型 | 说明 |
---|---|---|---|
appid | 是 | string | 应用ID |
time_stamp | 是 | string | 请求时间,格式为年月日时分秒,如:20240102123559 |
grant_type | 是 | string | 授权方式,固定为:API_TOKEN |
nonce_str | 是 | string | 随机字符串 |
token生成规则:
将参数名和值按字母顺序排序,并拼接成url参数方式,如:appid=123123&grant_type=API_TOKEN&nonce_str=123123123&time_stamp=20241128190400
以上字符串拼接上应用密钥【假设密钥是:1234567890abcdefg】,拼接成以下字符串:
appid=123123&grant_type=API_TOKEN&nonce_str=123123123&time_stamp=202411281904001234567890abcdefg
将此字符串进行MD5得到 6503c52b780307398d1b49a0df26d351 即token值
请求示例
{
"appid":"123123",
"time_stamp":"20241128190400",
"grant_type":"API_TOKEN",
"nonce_str":"123123123"
}
返回示例:
正确时返回:
{
"code": 200,
"data": {
"appid": "123123",
"token": "1_api_386807a8-2afe-4c1c-b19c-bcd4346c5009",
"timeout":7200
},
"msg": ""
}
错误时返回:
{
"code": 500,
"msg": "invalid appid",
"data": {
},
}
返回参数说明:
参数名 | 类型 | 说明 |
---|---|---|
token | string | 应用请求token,后续所有需要验证登录的接口,需要在header里增加token字段,值为此值 |
timeout | int | 此token的超时时间,单位:秒,超过此时间,需要重新获取token |
备注:
- 更多返回错误代码请看首页的错误代码描述
作者:宋德美 创建时间:2024-12-03 16:36
最后编辑:宋德美 更新时间:2024-12-08 14:43
最后编辑:宋德美 更新时间:2024-12-08 14:43