令牌创建¶
功能说明¶
- 根据
appid和appsecret获取access_token(开放平台接口的令牌,调用别的接口都需要此参数),此接口调用次数限制为60次/时,请注意缓存获取的access_token。 - 该接口一般是服务端之间的请求。
接口地址¶
- 测试环境: https://openapi.guanaitong.tech/token/create
- 生产环境: https://openapi.guanaitong.com/token/create
HTTP请求方式¶
- Method: POST
- Content-Type: application/x-www-form-urlencoded
参数说明¶
-
公有参数
此接口是开放平台唯一一个没有公用参数的接口,以私有参数为准
-
私有参数
| 参数名称 | 是否必须 | 参数类型 | 长度限制 | 描述 |
|---|---|---|---|---|
| appid | 是 | string | [32] | appid,由关爱通分配,唯一。 |
| grant_type | 否 | string | [17] | 固定为client_credential |
| timestamp | 是 | string | [10] | 时间戳,其值为1970-1-01 00:00:00.000到当前时刻的时间距离,单位是秒,时区为GMT+8(东八区)。如1469691921。关爱通接口允许的时间戳偏差为5分钟,偏差超过5分钟的请求将被拒绝。 |
| sign | 是 | string | [40] | SHA256签名,见“签名参数生成算法” |
| version | 否 | string | [5] | 业务接口版本号,如1.0.0 |
请求示例¶
POST /token/create HTTP/1.1
Host: openapi.guanaitong.tech
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
appid=30000003&grant_type=client_credential&sign=27e1f7bdf619e2bf3672fd9101ba010a2434c119&
timestamp=1494313879
返回参数说明¶
| 参数名称 | 描述 |
|---|---|
| code | 返回码。详见错误返回码。 |
| msg | 如果错误,返回错误信息。 |
| data | 如果没有错误,返回业务数据 |
| data.access_token | token生成接口生成的token |
| data.expires_in | token的有效时长,单位:s(秒) |
正确返回示例¶
{
"code": 0,
"data": {
"access_token": "cde2c369fab499c0bf0643bb1844e70c",
"expires_in": 3600
},
"msg": "OK"
}