Skip to content

Get a list of users who have certain resource permissions

This document is automatically generated based on https://github.com/authing/authing-docs-factory based on https://api-explorer.genauth.ai V3 API, and is consistent with API parameters and return results. If this document description is incorrect, please refer to V3 API.

Description

When you need to get users who have permissions for a specified resource, you can use this interface.

Scenario Example

If your business scenario is: you want to see the list of users who can edit the current document, then you can use this interface.

Request example

Get the list of authorized users for string and array resources

  • Input parameters
json
{
  "namespaceCode": "examplePermissionNamespace",
  "actions": ["get", "update", "read"],
  "resources": ["strResourceCode1", "arrayResourceCode1"]
}
  • Output parameters
json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 20001,
  "data": {
    "authUserList": [
      {
        "resource": "strResourceCode1",
        "actionAuthList": [
          {
            "userIds": ["63721xxxxxxxxxxxxdde14a3"],
            "action": "get"
          },
          {
            "userIds": ["63721xxxxxxxxxxxxdde14a3"],
            "action": "update"
          },
          {
            "userIds": ["63721xxxxxxxxxxxxdde14a3"],
            "action": "read"
          }
        ]
      },
      {
        "resource": "arrayResourceCode1",
        "actionAuthList": [
          {
            "userIds": ["63721xxxxxxxxxxxxdde14a3"],
            "action": "get"
          },
          {
            "userIds": ["63721xxxxxxxxxxxxdde14a3"],
            "action": "update"
          },
          {
            "userIds": ["63721xxxxxxxxxxxxdde14a3"],
            "action": "read"
          }
        ]
      }
    ]
  }
}

Example of getting a list of authorized users for a tree resource

  • Input parameter
json
{
"namespaceCode": "examplePermissionNamespace", "actions": ["get", "update", "delete"], "resources": [ "treeResourceCode1/StructCode1/resourceStructChildrenCode1", "treeResourceCode2/StructCode1/resourceStructChildrenCode1" ] } ``` - Outtake ```json { "statusCode": 200, "message": "Operation successful", "apiCode": 20001, "data": { "authUserList": [ { "resource": "treeResourceCode1/StructCode1/resourceStructChildrenCode1", "actionAuthList": [ { "userIds": ["63721xxxxxxxxxxxxdde14a3"], "action": "get" }, { "userIds": ["63721xxxxxxxxxxxxdde14a3"], "action": "update" }, { "userIds": ["63721xxxxxxxxxxxxdde14a3"], "action": "delete" } ] }, { "resource": "treeResourceCode2/StructCode1/resourceStructChildrenCode1", "actionAuthList": [ { "userIds": ["63721xxxxxxxxxxxxdde14a3"], "action": "get" }, { "userIds": ["63721xxxxxxxxxxxxdde14a3"], "action": "update" }, { "userIds": ["63721xxxxxxxxxxxxdde14a3"], "action": "delete" } ] }
]
}
}

Method name

ManagementClient.listResourceTargets

Request parameters

NameTypeRequiredDefault valueDescriptionSample value
resourcesstring[]Yes-Data resource path list to which the data policy belongs. Array length limit: 50.["treeResourceCode1"]
actionsstring[]Yes-Data resource permission operation list. Array length limit: 50.["get"]
namespaceCodestringyes-Permission space CodeexamplePermissionNamespace

Sample code

ts
import { ManagementClient, Models } from "authing-node-sdk";

// Initialize ManagementClient
const managementClient = new ManagementClient({
  // Need to be replaced with your GenAuth Access Key ID
  accessKeyId: "GEN_AUTH_ACCESS_KEY_ID",
  // Need to be replaced with your GenAuth Access Key Secret
  accessKeySecret: "GEN_AUTH_ACCESS_KEY_SECRET",
  // If it is a private deployment customer, you need to set the GenAuth service domain name
  // host: 'https://api.your-authing-service.com'
});

(async () => {
  const result = await managementClient.listResourceTargets({
    namespaceCode: "examplePermissionNamespace",
    actions: ["get", "update", "delete"],
    resources: [
      "strResourceCode",
      "arrayResourceCode",
      "/treeResourceCode/structCode/resourceStructChildrenCode",
    ],
  });

  console.log(JSON.stringify(result, null, 2));
})();

Request response

Type: ListResourceTargetsRespDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful. 200 means success.
messagestringDescription
apiCodenumberSegmented error code, which can be used to get the specific error type (successful request does not return). For a detailed list of error codes, see: API Code List
requestIdstringRequest ID. Returned when the request fails.
data<a ListResourceTargetsDataDtoResponse data

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
  "data": {
    "authUserList": {
      "resource": "treeResourceCode1",
      "actionAuthList": {
        "userIds": "[\"63721xxxxxxxxxxxxdde14a3\"]",
        "action": "get"
      }
    }
  }
}

Data structure

ListResourceTargetsDataDto

NameTypeIs it requiredDescriptionSample value
authUserListarrayYesUser authorization list Nested type: <a ListResourceTargetsDtoResp.

ListResourceTargetsDtoResp

NameTypeIs it required?DescriptionSample value
resourcestringYesResource pathtreeResourceCode1
actionAuthListarrayYesData resource permission operation list Nested type: <a ActionAuth.

ActionAuth

NameTypeRequiredDescriptionSample value
userIdsarrayyesData policy authorized user ID list["63721xxxxxxxxxxxxdde14a3"]
actionstringyesData resource permission operationget

Agent infrastructure for identity, memory, and web action.