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
|
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
|
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 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
requests |
Yes |
Array of AuthRequests objects |
Definition: Workspace authentication request body. |
|
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
|
Parameter |
Type |
Description |
|---|---|---|
|
results |
Array of ValidateAuthResults objects |
Definition: Authentication result. |
|
Parameter |
Type |
Description |
|---|---|---|
|
action |
String |
Definition: Fine-grained permission. Range: N/A |
|
verdict |
String |
Definition: Authentication result. Range
|
|
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. |
|
Parameter |
Type |
Description |
|---|---|---|
|
policy_name |
String |
Definition: Policy name. Range: N/A |
|
condition |
Array of Conditions objects |
Definition: Policy condition. |
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot