Link User with Permission

Last Updated on : 2023-10-09 08:09:03download

Based on the permission ID and user ID, link a user with the specified permission.

Note: - 1. Each user can be linked with no more than 10 permissions to avoid authorization flooding. - 2. The same permission ID can be granted to no more than 1,000 users.

API address

POST: /v2.0/cloud/iam/permission/{permission_id}/user/{user_id}

Request parameter

Parameter nameTypeINRequiredDescription
permission_idLonguritrueThe ID of the specified permission.
user_idStringuritrueThe user ID.

Description of body

Parameter nameTypeINRequiredDescription
attach_typeInteger trueThe authorization type. Valid values:
  • 0: generic authorization.
  • 1: temporary authorization.
start_timeLong falseThe time when a temporary authorization takes effect. Unit: milliseconds. This field is only valid for temporary authorization.
end_timeLong falseThe time when a temporary authorization expires. Unit: milliseconds. This field is only valid for temporary authorization.

Return parameter

Parameter nameTypeDescription
successBooleanIndicates whether the operation is successful. Valid values:
  • true: The operation succeeded.
  • false: The operation failed.
error_codeStringThe error code. For more information, see the error codes.
error_msgStringThe message that is returned if the request fails. It is empty if the request is successful.
resultObjectThe returned result.

Request example

POST: /v2.0/cloud/iam/permission/1/user/uid1
{
  "attach_type": 0
}

Return example

{
    "tid": "f5ffe2440b5111ee8144726abb6617ad",
    "result": true,
    "t": 1686815715734,
    "success": true
}

Error code

For more information, see error code.