注意:以下文档只适用于TOP接口,请谨慎使用!

文档中心 > API类目 > MOZI权限API

alibaba.mozi.acl.grant.grantrole (将一个角色授予一个账号)

根据入参,将入参中的角色授权给入参的某个账户,调用此接口后,该账户就会被授予该角色

公共参数

请求参数

名称 类型 是否必须 示例值 更多限制 描述
grant_roles_request GrantRolesRequest 必须 整体入参对象
  • └ reason
  • String
  • 必须
  • "将商品管理角色授予给小二张三"
  • 调用接口授角色的原因
  • └ target_app_name
  • String
  • 可选
  • “”
  • 目标应用名
  • └ request_meta_data
  • String
  • 可选
  • {""}
  • 扩展参数
  • principal
  • BucUserPrincipalParam
  • 必须
  • 授角色主体
  • └ tenant_id
  • Number
  • 必须
  • 10001
  • 授予角色的账号所在的租户Id
  • └ user_id
  • Number
  • 必须
  • 111411201
  • 授予角色的账号id
  • └ expire_date
  • Date
  • 可选
  • 2018-11-11 11:11:11
  • 授予角色的过期时间
  • └ role_names
  • String []
  • 必须
  • summer_test_top_role_01
  • 授予的角色的code列表

响应参数

名称 类型 示例值 描述
result GrantRolesResult {} 给账号授予角色结果
  • └ success
  • Boolean
  • true
  • 是否调用成功,成功则为true,否则为false
  • └ request_id
  • String
  • 1eqwdqf31112dsaf
  • 请求id
  • └ response_message
  • String
  • 成功
  • 响应信息,若失败,则返回失败信息
  • └ response_meta_data
  • String
  • {""}
  • 扩展字段,与入参扩展字段值相同
  • └ response_code
  • String
  • 0
  • 响应code

请求示例

  • JAVA
  • .NET
  • PHP
  • CURL
  • Python
  • C/C++
  • NodeJS
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlibabaMoziAclGrantGrantroleRequest req = new AlibabaMoziAclGrantGrantroleRequest();
AlibabaMoziAclGrantGrantroleRequest.GrantRolesRequest obj1 = new AlibabaMoziAclGrantGrantroleRequest.GrantRolesRequest();
obj1.setReason("\"将商品管理角色授予给小二张三\"");
obj1.setTargetAppName("“”");
obj1.setRequestMetaData("{\"\"}");
AlibabaMoziAclGrantGrantroleRequest.BucUserPrincipalParam obj2 = new AlibabaMoziAclGrantGrantroleRequest.BucUserPrincipalParam();
obj2.setTenantId(10001L);
obj2.setUserId(111411201L);
obj1.setPrincipal(obj2);
obj1.setExpireDate(StringUtils.parseDateTime("2018-11-11 11:11:11"));
obj1.setRoleNames("summer_test_top_role_01");
req.setGrantRolesRequest(obj1);
AlibabaMoziAclGrantGrantroleResponse rsp = client.execute(req);
System.out.println(rsp.getBody());

响应示例

  • XML示例
  • JSON示例
<alibaba_mozi_acl_grant_grantrole_response>
    <result>
        <success>true</success>
        <request_id>1eqwdqf31112dsaf</request_id>
        <response_message>成功</response_message>
        <response_meta_data>{&quot;&quot;}</response_meta_data>
        <response_code>0</response_code>
    </result>
</alibaba_mozi_acl_grant_grantrole_response>

异常示例

  • XML示例
  • JSON示例
<error_response>
    <code>50</code>
    <msg>Remote service error</msg>
    <sub_code>isv.invalid-parameter</sub_code>
    <sub_msg>非法参数</sub_msg>
</error_response>

错误码解释

错误码 错误描述 解决方案

API工具

如何获得此API

FAQ

返回
顶部