获取Access token接口
1.接口说明
应用于Authorization code授权模式,通过code获取accessToken。
2.接口URL
https://open.e.189.cn/api/oauth2/accessToken.do
3.支持格式
json/xml
4.HTTP请求方式
GET
5.请求参数
字段标识 | 说明 | 数据类型 | 长度(字节) | 可空 |
---|---|---|---|---|
clientId | 申请应用时分配的appId | String | 60 | N |
clientSecret | 申请应用时分配的appSecret | String | 100 | N |
grantType | 授权类型,authorization_code,authorization_msg | String | 20 | N |
code | 调用authorize/getMsgCode时返回的code | String | 100 | N |
redirectUri | 授权回调地址,必须和应用注册的地址一致 | String | 255 | N |
format | 数据返回格式,默认json | String | 10 | Y |
mobile | authorization_msg模式必须 | String | 20 | N |
extend | 扩展字段,json格式,如{alipayUserId:”123456”} | Json | Y |
6.请求样例
https://open.e.189.cn/api/oauth2/accessToken.do? clientId=13& clientSecret =345235434646346542354& grantType=9686765345& code=975673463242& redirectUri=xxx.do& format=json
7.返回参数
字段标识 | 说明 | 数据类型 | 长度(字节) | 可空 |
---|---|---|---|---|
result | 0表示成功,非0表示出错 | Integer | 4 | N |
accessToken | 访问第三方资源的凭证 | String | 100 | N |
expiresIn | accesstoken过期时间,以返回的时间的准,单位为秒,注意过期时提醒用户重新授权 | Long | N | |
refreshToken | 刷新token | String | 100 | N |
scope | token对应的授权能力代码列表,格式如code1,code2,code3 | String | 200 | N |
state | msg模式下传递的state值原样返回 | String | 100 | Y |
msg | result不为0的时候,该字段有值 | String | 256 | Y |
8.返回样例
正确返回样例: json示例: Content-type: text/html; charset=utf-8 { "result":0, "accessToken":"13800138000", "expiresIn":"3600", "refreshToken":”12800138000", "scope":"128_0013_8000" }
错误返回样例: json示例: Content-type: text/html; charset=utf-8 { "result":-1, "msg":"获取token失败" }
使用范例