文档
测试

1 登陆-/oauth/token

POST
/oauth/token

接口描述

登陆接口,返回token,参数是form表单

请求头

参数名
类型
描述
必填
Authorization
string
与下方参数(client_id,client_secret)必选一个,Authorization的值是由client_id+client_secret计算出来的
必填
Content-Type
string
application/x-www-form-urlencoded form表单格式
必填

请求参数-form表单格式

参数名
类型
描述
必填
grant_type
string
(必填)登陆类型
必填
username
string
(必填)用户名
必填
password
string
(必填)密码
必填
client_id
string
客户端id(与上方请求头中的Authorization必选一个)
必填
client_secret
string
客户端密码(与上方请求头中的Authorization必选一个)
必填
code
string
验证码,如需要则加上此字段
必填
clusterCode
string
邀请码
必填
client
string
当客户端是管理员版本时值为:manager
必填

响应参数-json格式

参数名
类型
描述
必填
code
int
1000:多个clusterCode,1001:clusterCode错误,1002:其他错误,1004:用户不存在
必填
message
string
网关提示的错误信息
必填
success
boolean
true/false;是否请求成功
必填
cluster_code
string
邀请码;code=200时返回
必填
access_token
string
登陆token;code=200时返回
必填
sso_url
string
sso服务地址;code=200时返回
必填
server_url
string
server服务地址;code=200时返回
必填
error_description
string
当code=1002时,error_description=2001表示要输入验证码,error_description=4006表示用户不存在,其他则直接提示用户
必填

说明 / 示例

![喵呜](https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1590830677729&di=f7742f2c80c74937d001751ee081ca53&imgtype=0&src=http%3A%2F%2Fimage.biaobaiju.com%2Fuploads%2F20190114%2F21%2F1547472226-uKAvJCHVgG.jpeg) ## 网关逻辑 ### 网关校验 - username:不能为空,为空->返回1002 - password:不能为空,为空->返回1002 - clusterCode: - 无默认clusterCode - 邀请码输入,不存在我们系统时,返回1001 - 邀请码输入,存在我们系统时,与用户未对应,返回1001 - 邀请码不输入时,根据username从本地缓存找,若未找到则从redis找,还未找到->返回用户不存在code=1004 - 根据username查询到多个clusterCode->返回1000和clusterCode - 根据username查询到单个clusterCode->直接登陆 ## 请求登陆成功 #### 返回示例 ```json { "cluster_code": "TEST0525", "scope": "all", "refresh_token": "92427658-f13a-4dda-8345-36ec611fd943", "token_type": "bearer", "access_token": "3d3fe7ea-14ce-4783-9be2-50aa7d821c55", "code": 200, "sso_url": "http://39.102.45.111:9000/sso", "expires_in": 71830653, "server_url": "http://39.102.45.111:9000/server" } ``` ## 请求登陆失败 ## code=1000 一个用户多个clusterCode #### 返回示例 ```json { "message": "用户存在多个邀请码", "cluster_codes": [ { "cluster_code": "TEST0525", "name": "测试用" }, { "name": "北京市教委环境", "cluster_code": "BJEDU" } ], "code": 1000 } ``` ## code=1001 邀请码错误 #### 返回示例 ```json { "data": null, "message": "邀请码错误", "success": false, "code": 1001 } ``` ## code=1002 后端返回登陆信息错误 当code=1002时,error_description=2001表示要输入验证码,error_description=4006表示用户不存在,其他则直接提示用户 #### 返回示例 ```json { "message": "登陆sso返回错误信息", "code": 1002, "error_description": "password not match!", "success": false, "cluster_code":TEST0525, "error": "access_denied" } ``` ## code=1004 用户不存在 #### 返回示例 ```json { "data": null, "message": "用户不存在", "success": false, "code": 1004 } ```