GenAuth DocsDocuments
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Old version
  • Single Page Web Application

  • Mobile and Client Applications

  • Standard Web Application

    • Java

    • Node.js

    • Python

      • 安装使用
      • 用户认证模块
      • 管理模块

        • 用户管理

        • 分组管理

        • 角色管理

        • 组织机构管理

        • 访问控制管理

        • 外部身份源管理

        • 自定义字段管理

          • 获取用户池配置的自定义字段列表
          • 创建/修改自定义字段定义
          • 设置自定义字段的值
          • 获取用户、分组、角色、组织机构的自定义字段值
  • Framework Integration

  • Others

  1. Development Integration
  2. /
  3. Standard Web Application
  4. /
  5. Python
  6. /
  7. 管理模块

  8. /
  9. 自定义字段管理

  10. /
  11. 设置自定义字段的值

¶ 设置自定义字段的值

Update time: 2025-07-23 07:34:21
Edit

给用户、角色、部门设置自定义字段的值,如果存在则更新,不存在则创建。

¶ 请求参数

名称类型必填默认值描述示例值
listSetCustomDataDto[]是-自定义数据列表。
targetIdentifierstring是-主体类型的唯一标志符。如果是用户则为用户 ID,角色为角色的 code,部门为部门的 ID。userId1
targetTypestring是-主体类型,目前支持用户、角色、分组、部门。 枚举值:USER,ROLE,GROUP,DEPARTMENTUSER
namespacestring否-所属权限分组的 code,当 target_type 为角色的时候需要填写,否则可以忽略。default

¶ 示例代码

from authing import ManagementClient

management_client = ManagementClient(
    access_key_id="GEN_AUTH_USERPOOL_ID",
    access_key_secret="GEN_AUTH_USERPOOL_SECRET",
)

data = management_client.set_custom_data(
     target_type: "USER",
     target_identifier: "userId1",
     namespace: "default",
     list: [{
           key: "school",
         value: "pku",
      }],

)

¶ 请求响应

类型: IsSuccessRespDto

名称类型描述
statusCodenumber业务状态码,可以通过此状态码判断操作是否成功,200 表示成功。
messagestring描述信息
apiCodenumber细分错误码,可通过此错误码得到具体的错误类型。
dataIsSuccessDto操作是否成功

示例结果:

{
  "statusCode": 200,
  "message": "操作成功",
  "apiCode": 20001,
  "data": {
    "success": true
  }
}

¶ 数据结构

¶ SetCustomDataDto

名称类型必填描述
keystring是字段 key,不能和内置字段的 key 冲突。 示例值: school
valuestring是自定义数据,可以为任意类型,但是必须和创建时定义的自定义字段类型匹配,否则将设置失败。 示例值: pku

¶ IsSuccessDto

名称类型必填描述
successboolean是操作是否成功。 示例值: true
Previous article: 创建/修改自定义字段定义 Next article: 获取用户、分组、角色、组织机构的自定义字段值
  • 请求参数
  • 示例代码
  • 请求响应
  • 数据结构

User identity management

Integrated third-party login
Customized authentication process

Enterprise internal management

Single sign-on
Multi-factor authentication
Permission management

Developer

Development Documentation
GitHub (opens new window)

Company

official@genauth.ai
16th Floor, Building B, Beichen Century Center, Chaoyang District, Beijing (Total)
Room 406, 4th Floor, Block B, No. 200, Tianfu Fifth Street, High-tech Zone, Chengdu (Branch)

© Beijing Steamory Technology Co., Ltd.