Skip to content

OAuth2认证接口

接口名称接口说明详细说明
令牌接口/api/sso/authz/oauth/v20/token获取授权过的 Access Token应用获取access_token,调用接口进行 code 校验;
校验成功获取访问 access_token
用户属性接口/api/sso/authz/oauth/v20/me授权用户信息查询接口通过访问 token 获取登录用户信息

令牌接口

项目详情
接口名称token 接口
url/api/sso/authz/oauth/v20/token
请求方式get, post

请求参数

参数是否必填说明
client_id注册应用时分配的client_id
client_secret注册应用时分配的client_secret
redirect_uri应用回调地址,必须和注册时配置的一致
code单点登录重定向回调生成的code
grant_type授权类型,固定值 authorization_code
etc param其他参数

返回值字段

参数类型说明
access_tokenstringaccess_token
token_typestring令牌类型
expires_instring过期时间(s)
scopestring作用域

请求示例

curl
GET /api/sso/authz/oauth/v20/token?client_id=QPKKKSADFUP876&grant_type=authorization_code&redirect_uri=http://apphost:appport/app/callback&code=c07db97a-fde8-4e17-8fb9-735637980774&client_secret=client_secret HTTP/1.1

POST /api/sso/authz/oauth/v20/token token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
code= PQ7q7W91a-oMsCeLvIaQm6bTrgtp7&
client_id=QPKKKSADFUP876&
client_secret=client_secret&
grant_type=authorization_code&
redirect_uri=http://apphost:appport/app/callback

返回值

{
  "access_token": "b453107f-0a9b-497f-b2a4-16233fd3e776",
  "token_type": "bearer",
  "expires_in": 17999,
  "scope": "authorization_code phone email profile"
}

用户属性接口

接口名称url请求方式
token 接口/api/sso/authz/oauth/v20/mehttp get/post

请求参数

参数说明
access_token调用sso/token获得的token值。

返回值字段

字段类型说明
birthdaystring生日(yyyy-MM-dd)
genderinteger性别,1:男,2:女
displayNamestring显示名称
departmentIdstring部门ID
departmentstring部门名称
mobilestring手机号码
createdatestring创建时间(yyyy-MM-dd HH:mm:ss)
titlestring职务
userIdstring用户ID
online_ticketstring
employeeNumberstring工号
realnamestring姓名-同显示名称
institutionstring机构/租户
randomIdstring随机ID
idstring用户ID
statestring工作-省/市
userstring用户
emailstring邮箱
usernamestring用户名

请求示例

curl

POST /oauth/ userinfo HTTP/1.1
Content-Type: application/x-www-form-urlencoded
access_token= PQ7q7W91a-oMsCeLvIaQm6bTrgtp7

返回值
{
  "birthday": null,
  "gender": 1,
  "displayName": "系统管理员",
  "departmentId": "",
  "mobile": "",
  "createdate": "2022-09-08 21:49:40",
  "title": "系统管理员",
  "userId": "1",
  "online_ticket": "OT_1094233574443319296",
  "employeeNumber": "",
  "realname": "系统管理员",
  "institution": "1",
  "randomId": "baa48030-b7b6-4d92-9ce1-4efaf8658b3b",
  "id": "1",
  "state": "北京",
  "department": "",
  "user": "admin",
  "email": "",
  "username": "admin"
}