查询单个用户授权
查询飞书人事管理后台里 -「设置」-「权限设置」中的单个用户授权信息。授权信息中包括员工ID、被授权的角色等信息。
请求
| 项目 | 值 |
|---|---|
| HTTP URL | https://open.feishu.cn/open-apis/corehr/v1/authorizations/get_by_param |
| HTTP Method | GET |
| 接口频率限制 | 20 次/分钟 |
| 支持的应用类型 | custom,isv |
| 权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 开启任一权限即可 | corehr:corehr:readonly 获取核心人事信息 corehr:corehr 更新核心人事信息 corehr:authorization:write 更新用户权限 |
| 字段权限要求 | > Tip: 该接口返回体中存在下列敏感字段,仅当开启对应的权限后才会返回;如果无需获取这些字段,则不建议申请 contact:user.employee_id:readonly 获取用户 user ID |
请求头
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | string | 是 | tenant_access_token 值格式:"Bearer access_token" 示例值:"Bearer t-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token |
查询参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
employment_id | string | 是 | 被授权用户的 ID,ID类型与user_id_type的取值意义一致。默认为飞书人事中的 ==employment_id==。 > 如果你需要不同类型的ID进行转换,可以使用 ID转换服务 换取 ==employment_id== 示例值:67489937334909845 |
user_id_type | string | 否 | 用户 ID 类型 示例值:people_corehr_id 可选值有: - open_id: 标识一个用户在某个应用中的身份。同一个用户在不同应用中的 Open ID 不同。了解更多:如何获取 Open ID - union_id: 标识一个用户在某个应用开发商下的身份。同一用户在同一开发商下的应用中的 Union ID 是相同的,在不同开发商下的应用中的 Union ID 是不同的。通过 Union ID,应用开发商可以把同个用户在多个应用中的身份关联起来。了解更多:如何获取 Union ID? - user_id: 标识一个用户在某个租户内的身份。同一个用户在租户 A 和租户 B 内的 User ID 是不同的。在同一个租户内,一个用户的 User ID 在所有应用(包括商店应用)中都保持一致。User ID 主要用于在不同的应用间打通用户数据。了解更多:如何获取 User ID? - people_corehr_id: 以飞书人事的 ID 来识别用户默认值: people_corehr_id当值为 user_id,字段权限要求: contact:user.employee_id:readonly 获取用户 user ID |
响应
响应体
| 名称 | 类型 | 描述 |
|---|---|---|
code | int | 错误码,非 0 表示失败 |
msg | string | 错误描述 |
data | \- | - |
└ role_authorization | role_authorization | 角色授权信息 |
└ employment_id | string | 员工 ID > 可以使用搜索员工信息接口获取员工其他信息。 |
└ permission_detail_list | permission_detail\[\] | 授权列表。 “按组织架构管理”的角色保留assigned_organization_ list<br>“不按组织架构管理” 角色保留grantor_rule_list |
└ role | security_group | 角色 |
└ id | string | 角色 ID |
└ code | string | 角色 code,通常用于与其他系统进行交互 |
└ name | name | 角色名称 |
└ zh_cn | string | 中文 |
└ en_us | string | 英文 |
└ description | name | 角色描述 |
└ zh_cn | string | 中文 |
└ en_us | string | 英文 |
└ org_truncation | org_truncation\[\] | 组织管理维度 |
└ org_key | string | 组织管理维度名称 |
└ type | int | 下钻类型 - 0 = 对当前管理维度及下级管理维度均有权限 - 1 = 只对当前管理维度有权限,不包含其下级管理维度 |
└ depth | int | 下钻深度,层 |
└ assigned_organization_list | assigned_organization\[\]\[\] | 「按组织架构管理」角色的数据范围。 「不按组织架构管理」的角色不返回该字段。 |
└ grantor_rule_list | permission_security_group\[\] | 「不按组织架构管理」角色的数据范围。 「按组织架构管理」的角色不返回该字段。 |
└ rule_dimension | rule_dimension | 权限实体 |
└ entity_key | string | 权限实体的 key,例如:user(员工)、department(部门) |
└ entity_name | name | 维度名称,例如:员工、部门 |
└ zh_cn | string | 中文 |
└ en_us | string | 英文 |
└ rule_type | int | 数据范围 - 0:无数据权限 - 1:全部数据权限 - 2:被授权的用户自己 - 3:按规则指定范围 |
└ expression | filter_expression | 数据范围表达式 |
└ conditions | filter_condition\[\] | 筛选条件 |
└ left | filter_rule_value | 左值 |
└ type | int | 左值数据类型(value的类型) - 0 = 字符串 - 1 = 数字 - 2 = 字符串数组 - 3 = 数字数组 |
└ value | string | 规则值 |
└ lookup_value | string | 下钻值 |
└ lookup_type | string | 下钻类型 |
└ right | filter_rule_value | 右值 |
└ type | int | 右值数据类型(value的类型) - 0 = 字符串 - 1 = 数字 - 2 = 字符串数组 - 3 = 数字数组 |
└ value | string | 规则值 |
└ lookup_value | string | 下钻值 |
└ lookup_type | string | 下钻类型 |
└ operator | int | 操作符 |
└ right_value_type | int | 右值类型 - 1 = 指定值 - 2 = 引用 |
└ logic_expression | string | 表达式 |
└ update_time | string | 更新时间(时间戳,单位:s) |
响应体示例
json
{
"code": 0,
"msg": "success",
"data": {
"role_authorization": {
"employment_id": "6967639606963471902",
"permission_detail_list": [
{
"role": {
"id": "7034393015968122400",
"code": "department_manager",
"name": {
"zh_cn": "部门经理",
"en_us": "department manager"
},
"description": {
"zh_cn": "描述",
"en_us": "description"
},
"org_truncation": [
{
"org_key": "department",
"type": 0,
"depth": 0
}
]
},
"assigned_organization_list": [
[
{
"org_key": "department",
"org_name": {
"zh_cn": "部门",
"en_us": "department"
},
"org_id_list": [
"6967639606963471902"
]
}
]
],
"grantor_rule_list": [
{
"rule_dimension": {
"entity_key": "员工",
"entity_name": {
"zh_cn": "员工",
"en_us": "User"
}
},
"rule_type": 1,
"expression": {
"conditions": [
{
"left": {
"type": 1,
"value": "a",
"lookup_value": "1",
"lookup_type": "user"
},
"right": {
"type": 1,
"value": "a",
"lookup_value": "1",
"lookup_type": "user"
},
"operator": 1,
"right_value_type": 1
}
],
"logic_expression": "1 and 2"
}
}
],
"update_time": "1720584039"
}
]
}
}
}错误码
| HTTP状态码 | 错误码 | 描述 | 排查建议 |
|---|---|---|---|
| 400 | 1161404 | Missing or invalid parameter | 参数缺失或无效,请检查参数是否缺失或格式是否符合要求 |
| 500 | 1161501 | System internal error | 请参考详细错误信息,如有问题请咨询技术支持 |
