Help Center/ ModelArts/ API Reference/ Workspace Management/ Authenticating Whether the Current Workspace Can Be Used
Updated on 2025-11-19 GMT+08:00

Authenticating Whether the Current Workspace Can Be Used

Function

This API is used to check whether a user has the permission to access and use resources in the current workspace. This API is used when you try to access or operate resources in the workspace, and the system needs to check whether you have the required permission. Before using this API, ensure that you have logged in and the workspace exists. If the authentication is successful, the user can access and use resources in the workspace. If the authentication fails, the API returns an error message, for example, insufficient permissions or the workspace does not exist.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST /v1/{project_id}/workspaces/{workspace_id}/auth

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

workspace_id

Yes

String

Definition: Workspace ID. For details about how to obtain the value, see Obtaining Workspaces. If no workspace is created, the default value is 0. If a workspace is created and used, use the actual value.

Constraints: N/A

Range: N/A

Default Value: 0

project_id

Yes

String

Definition: User project ID. For details, see Obtaining a Project ID and Name.

Constraints: The value can contain 1 to 64 characters. Letters, digits, and hyphens (-) are allowed.

Range: N/A

Default Value: N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition: Requests for calling an API can be authenticated using either a token or AK/SK. If token-based authentication is used, this parameter is mandatory and must be set to a user token. For details, see Obtaining a User Token.

Constraints: N/A

Range: N/A

Default Value: N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

requests

Yes

Array of AuthRequests objects

Definition: Workspace authentication request body.

Table 4 AuthRequests

Parameter

Mandatory

Type

Description

action_id

Yes

String

Definition: Random UUID, which is used for locating.

Range: N/A

action

Yes

String

Definition: Fine-grained action.

Range: N/A

resource

No

String

Definition: Resource ID.

Range: N/A

service_attributes

No

Map<String,String>

Definition: Operation object.

Range: N/A

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

results

Array of ValidateAuthResults objects

Definition: Authentication result.

Table 6 ValidateAuthResults

Parameter

Type

Description

action

String

Definition: Fine-grained permission.

Range: N/A

verdict

String

Definition: Authentication result.

Range

  • allow: Authenticated.

  • deny: Authentication failed.

action_id

String

Definition: Random UUID, which is used to locate faults.

Range: N/A

resource

String

Definition: Request resource.

Range: N/A

cause

Array of Cause objects

Definition: Failure cause.

Table 7 Cause

Parameter

Type

Description

policy_name

String

Definition: Policy name.

Range: N/A

condition

Array of Conditions objects

Definition: Policy condition.

Table 8 Conditions

Parameter

Type

Description

key

String

Definition: Operation attribute.

Range: N/A

operator

String

Definition: Operator.

Range: N/A

value

Array of strings

Definition: Operator value.

Example Requests

Authenticate whether the current user can perform operations in the current workspace.

POST https://{endpoint}/v1/{projectId}/workspaces/{workspaceId}/auth

{
  "requests" : [ {
    "action_id" : "cf6ad5b9_bd73_4354_b663_364348597e29",
    "action" : "modelarts:trainJob:get"
  } ]
}

Example Responses

Status code: 200

Response body for workspace authentication.

{
  "results" : [ {
    "action" : "modelarts:trainJob:get",
    "verdict" : "allow",
    "action_id" : "cf6ad5b9_bd73_4354_b663_364348597e29",
    "resource" : null,
    "cause" : null
  } ]
}

Status Codes

Status Code

Description

200

Response body for workspace authentication.

Error Codes

See Error Codes.