开发者社区> 问答> 正文

如何删除授权

OnsEmpowerDelete 接口可以对已经创建的授权关系进行删除,以解除之前创建的跨账号访问资源的权限。

使用场景

在创建授权后,如果需要解除跨账号的 Topic 访问权限,Owner 账号可以调用该接口解除。

注意事项:

调用方必须是资源的 Owner 账号。
需要删除的授权信息必须存在。
请求参数列表

名称    类型    是否必须    描述
OnsRegionId    String    是    当前查询 MQ 所在区域,可以通过 OnsRegionList 方法获取
OnsPlatform    String    否    该请求来源,默认是从 POP 平台
PreventCache    Long    是    用于 CSRF 校验,设置为系统当前时间即可
EmpowerUser    Long    是    授权的目标用户 User ID,支持子账号 ID
Topic    String    是    授权的目标 Topic,该 Topic 必须是当前用户所有
返回参数列表

名称    类型    描述
RequestId    String    为公共参数,每个请求独一无二
HelpUrl    String    帮助链接
相关 API

OnsEmpowerCreate:创建授权接口
OnsEmpowerList:查看授权信息接口
使用示例

    public static void main(String []args) {
            public static void main(String []args) {
                    String regionId = "cn-hangzhou";
                    String accessKey = "XXXXXXXXXXXXXXXXX";
                    String secretKey = "XXXXXXXXXXXXXXXXX";
                    String endPointName ="cn-hangzhou";
                    String productName ="Ons";
                    String domain ="ons.cn-hangzhou.aliyuncs.com";
                    /**
                    *根据自己需要访问的区域选择Region,并设置对应的接入点
                    */
                    try {
                        DefaultProfile.addEndpoint(endPointName,regionId,productName,domain);
                    } catch (ClientException e) {
                        e.printStackTrace();
                    }
                    IClientProfile profile= DefaultProfile.getProfile(regionId,accessKey,secretKey);
                    IAcsClient iAcsClient= new DefaultAcsClient(profile);
                   OnsEmpowerDeleteRequest request = new OnsEmpowerDeleteRequest();
                   request.setOnsRegionId("cn-qingdao-publictest");
                   request.setPreventCache(System.currentTimeMillis());
                   request.setAcceptFormat(FormatType.JSON);
                   request.setEmpowerUser("16753563236808602");
                   request.setTopic("topic_for_public_msg_test");
                   try {
                       OnsEmpowerDeleteResponse response=iAcsClient.getAcsResponse(request);
                       System.out.println(response.getRequestId());
                   } catch (ServerException e) {
                       e.printStackTrace();
                   } catch (ClientException e) {
                       e.printStackTrace();
                   }
                }

展开
收起
猫饭先生 2017-10-27 14:00:55 1700 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载