Skip to content

Get the structure list of resources authorized by the user under the logged-in application

Get the list of resources authorized by the user, the user gets the structure list authorized by a resource under a certain application, and returns the authorization list of the corresponding resource through different resource types.

Method name

AuthenticationClient.getUserAuthResourceStruct

Request parameters

Type: GetUserAuthResourceStructDto

NameTypeRequiredDefault valueDescriptionExample value
resourcestringYes-Data resource Code"exampleResource"

Sample code

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

const authenticationClient = new AuthenticationClient({
  // Need to be replaced with your GenAuth AppId, Secret and Host
  appId: "GEN_AUTH_APP_ID",
  appSecret: "GEN_AUTH_APP_SECRET",
  appHost: "GEN_AUTH_APP_HOST",
});

(async () => {
  const user = await authenticationClient.signInByUsernamePassword(
    "Username",
    "Password"
  );
  // Please call the login interface to get access_token first, and call the setAccessToken method to set access_token
  authenticationClient.setAccessToken(user.data.accessToken);
  const result = await authenticationClient.getUserAuthResourceStruct({
    resource: "treeExampleResourceCode",
  });
  console.log(JSON.stringify(result, null, 2));
})();

Request response

Type: GetUserAuthResourceStructRespDto

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. Returned when the request fails.
data<a GetUserAuthResourceStructDataDtoResponse data

Sample result:

json
{
"statusCode": 200,
"message": "Operation successful",
"apiCode": 0,
"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": "Subnode 2",
"value": "Subnode 2 value",
"actions": ["get"]
}
]
}
]
}
]
}
}

Data structure

GetUserAuthResourceStructDataDto

NameTypeIs it requiredDescriptionSample value
namespaceCodestringYesPermission space CodenamespaceCode
resourceCodestringYesData resource CoderesourceCode
resourceTypestringYesData resource type, nested type, <a ResourceType. Currently supports three types: tree structure (TREE), string (STRING), array (ARRAY), and returns different structures 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.

ResourceType

NameTypeDescription
STRINGenumString type
ARRAYenumArray type
TREEenumTree type

StrResourceAuthAction

NameTypeIs it required?DescriptionSample value
valuestringYesValue of a string data resourceresourceValue
actionsstring[]YesList of permission operations for a string data resource["read","get"]

ArrResourceAuthAction

NameTypeIs it required?DescriptionSample value
valuesstring[]YesArray data resource's Values["resourceValue1","resourceValue2"]
actionsstring[]YesArray data resource's permission operation list["read","get"]

TreeResourceAuthAction

NameTypeIs it required?DescriptionSample value
nodeAuthActionListTreeStructs[]YesTree 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[]YesPermission operation list of tree data resource policy noderead
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.