微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

identity.v1beta1.devices创建403错误

如何解决identity.v1beta1.devices创建403错误

我正在尝试使用这种资源来创建新设备:

https://cloud.google.com/identity/docs/reference/rest/v1beta1/devices/create

我已经定义了API的范围,如下所示。

    @Override
    protected List<String> getScopes() {
        return Collections.singletonList(
                "https://www.googleapis.com/auth/cloud-identity"
        );
    }

我正在这调用API创建方法

            val createDeviceRequest = new CreateDeviceRequest()
                    .setCustomer("customers/my_customer")
                    .setDevice(createDeviceModel.toGoogle());
            
            cloudIdentityClientFactory
                    .createFor(adminGoogleId)
                    .devices()
                    .create(createDeviceRequest)
                    .execute();

“ createDeviceRequest”实体值如下:

enter image description here

创建客户端没有错误,因为创建客户端可以正常工作,并且我可以调用列表终结点并在响应正文中使用3个设备获得成功响应。我知道该范围很好,因为我仅使用上面定义的1个范围,并且可以访问列表设备。

https://cloud.google.com/identity/docs/reference/rest/v1beta1/devices/list

一个可以正常工作的列表设备示例:

            val x = cloudIdentityClientFactory
                    .createFor(adminGoogleId)
                    .devices()
                    .list()
                    .setCustomer("customers/my_customer")
                    .execute();

当我尝试调用创建端点时,出现403 Forbidden错误。我想知道此禁止消息的原因是什么,有什么办法可以解决它。

POST https://cloudidentity.googleapis.com/v1beta1/devices
{
  "code" : 403,"errors" : [ {
    "domain" : "global","message" : "The caller does not have permission","reason" : "forbidden"
  } ],"status" : "PERMISSION_DENIED"
}

谢谢。

解决方法

我建议您改为发布问题on Github

他们可能会更好地回答您有关Java和GCP API的问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?