主题
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_token | string | access_token |
token_type | string | 令牌类型 |
expires_in | string | 过期时间(s) |
scope | string | 作用域 |
请求示例
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/me | http get/post |
请求参数
参数 | 说明 |
---|---|
access_token | 调用sso/token获得的token值。 |
返回值字段
字段 | 类型 | 说明 |
---|---|---|
birthday | string | 生日(yyyy-MM-dd) |
gender | integer | 性别,1:男,2:女 |
displayName | string | 显示名称 |
departmentId | string | 部门ID |
department | string | 部门名称 |
mobile | string | 手机号码 |
createdate | string | 创建时间(yyyy-MM-dd HH:mm:ss) |
title | string | 职务 |
userId | string | 用户ID |
online_ticket | string | |
employeeNumber | string | 工号 |
realname | string | 姓名-同显示名称 |
institution | string | 机构/租户 |
randomId | string | 随机ID |
id | string | 用户ID |
state | string | 工作-省/市 |
user | string | 用户 |
string | 邮箱 | |
username | string | 用户名 |
请求示例
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"
}