Skip to content

Get the structure list of user authorized resources

This interface is mainly used to obtain the user authorized resource list, and obtain the user resource authorization list through the permission space Code, user id, and resource Code.

Example of getting user authorization string data resource

  • Input
json
{
  "namespaceCode": "examplePermissionNamespace",
  "userId": "63721xxxxxxxxxxxxdde14a3",
  "resourceCode": "exampleStrResourceCode"
}
  • Output
json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 20001,
  "data": {
    "namespaceCode": "exampleNamespaceCode",
    "resourceCode": "exampleStrResourceCode",
    "resourceType": "STRING",
    "strResourceAuthAction": {
      "value": "strTestValue",
      "actions": ["get", "delete"]
    }
  }
}

Example of getting user authorization data array resource

  • Input
json
{
  "namespaceCode": "examplePermissionNamespace",
  "userId": "63721xxxxxxxxxxxxdde14a3",
  "resourceCode": "exampleArrResourceCode"
}
  • Output parameters
json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 20001,
  "data": {
    "namespaceCode": "exampleNamespaceCode",
    "resourceCode": "exampleArrResourceCode",
    "resourceType": "ARRAY",
    "arrResourceAuthAction": {
      "values": ["arrTestValue1", "arrTestValue2", "arrTestValue3"],
      "actions": ["get", "delete"]
    }
  }
}

Example of obtaining user authorization tree data resources

  • Input parameters
json
{
"namespaceCode": "examplePermissionNamespace", "userId": "63721xxxxxxxxxxxxdde14a3", "resourceCode": "exampleArrResourceCode" } ``` - Outtake ```json { "statusCode": 200, "message": "Operation successful", "apiCode": 20001, "data": { "namespaceCode": "exampleNamespaceCode", "resourceCode": "exampleArrResourceCode", "resourceType": "TREE", "treeResourceAuthAction": { "nodeAuthActionList": [ { "code": "tree11", "name": "tree11", "value": "test11Value", "actions": ["get", "delete"], "children": [ { "code": "tree111", "name": "tree111", "value": "test111Value", "actions": ["update", "read"]
}
]
},
{
"code": "tree22",
"name": "tree22",
"value": "test22Value",
"actions": ["get", "delete"]
}
]
}
}
}

Method name

ManagementClient.getUserResourceStruct

Request parameters

Type: GetUserResourceStructDto

NameTypeIs it requiredDefault valueDescriptionSample value
namespaceCodestringYes-Permission space CodeexamplePermissionNamespace
resourceCodestringyes-Resource CodeexampleResourceCode
userIdstringyes-User ID6301ceaxxxxxxxxxxx27478

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.getUserResourceStruct({
    // Replace user ID
    namespaceCode: "examplePermissionNamespace",
    resourceCode: "arrResourceCode",
    userId: "63721xxxxxxxxxxxxdde14a3",
  });

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

Request response

Type: GetUserResourceStructRespDto

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.
requestIdstringRequest ID. It will be returned when the request fails.
data<a GetUserResourceStructDataDtoResponse data

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "apiCode": 0,
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
  "data": {
    "namespaceCode": "namespaceCode",
    "resourceCode": "resourceCode",
    "resourceType": "TREE",
    "treeResourceAuthAction": {
      "nodeAuthActionList": [
        {
          "code": "123",
          "name": "Tree data resource",
          "value": "Sample tree resource policy node",
          "actions": "read",
          "children": [
            {
              "code": "code1",
              "name": "Child node 1",
              "value": "Child node value",
              "actions": ["Create"],
              "children": [
                {
                  "code": "code2",
                  "name": "Child node 2",
                  "value": "Child node 2 value",
                  "actions": ["get"]
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

Data structure

GetUserResourceStructDataDto

NameTypeIs it required?DescriptionSample value
namespaceCodestringYesPermission space codenamespaceCode
resourceCodestringYesResource coderesourceCode
resourceTypestringYesData resource type, nested type, <a ResourceType. Currently, three types of structures are supported: tree structure (TREE), string (STRING), and array (ARRAY). Different structures are returned according to different types.
- STRING: string type result StrResourceAuthAction.
- ARRAY: array type ArrResourceAuthAction.
- TREE: tree type TreeResourceAuthAction.
strResourceAuthActionStrResourceAuthActionNoString resource authorization structure, nested type: <a StrResourceAuthAction.
arrResourceAuthActionArrResourceAuthActionNoArray resource authorization structure, nested type: <a ArrResourceAuthAction.
treeResourceAuthActionTreeResourceAuthActionNoTree resource authorization structure, nested type: <a TreeResourceAuthAction. Tree resource authorization

ResourceType

NameTypeDescription
STRINGenumString type
ARRAYenumArray type
TREEenumTree type

StrResourceAuthAction

NameTypeIs it required?DescriptionSample value
valuestring[]YesValue of a string data resourceresourceValue
actionsarrayYesList of permission operations for string data resources["read","get"]

ArrResourceAuthAction

NameTypeRequiredDescriptionSample value
valuesstring[]YesValues of array data resources["resourceValue1","resourceValue2"]
actionsstring[]YesList of permission operations for array data resources["read","get"]

TreeResourceAuthAction

NameTypeIs it required?DescriptionSample value
nodeAuthActionListarrayYesTree structure node list, nested type: <a TreeStructs.-

TreeStructs

NameTypeIs it required?DescriptionSample value
codestringYesTree resource node Code, unique at the same level123
namestringYesTree resource node name, unique at the same levelData resource
valuestringNoTree resource node ValueSample resource policy node
actionsstring[]YesList of permission operations for tree data resource policy nodesread
childrenTreeStructsNoChild node data, child node data has a maximum of five levels, nesting type: <a TreeStructs.[{"code":"code1","name":"child node 1","value":"child node value","enabled":false,"action":"create","children":[{"code":"code2","name":"child node 2","value":"child node 2 value","enabled":true,"action":"get"}]}]

Agent infrastructure for identity, memory, and web action.