I am trying to create a new device with this resouce:
https://cloud.google.com/identity/docs/reference/rest/v1beta1/devices/create.
I have defined the scopes for the API like below.
@Override
protected List<String> getScopes() {
return Collections.singletonList(
"https://www.googleapis.com/auth/cloud-identity"
);
}
I am calling the API create method like this.
val createDeviceRequest = new CreateDeviceRequest()
.setCustomer("customers/my_customer")
.setDevice(createDeviceModel.toGoogle());
cloudIdentityClientFactory
.createFor(adminGoogleId)
.devices()
.create(createDeviceRequest)
.execute();
"createDeviceRequest" entity value is like this:
There is no error about creating the client because creating the client works fine and I am able to call the list endpoint and get success response with 3 devices in the response body. I understand that the scope works fine because I am only using the 1 scope defined above and I have access to the listing devices.
https://cloud.google.com/identity/docs/reference/rest/v1beta1/devices/list
An example for the listing devices which works fine:
val x = cloudIdentityClientFactory
.createFor(adminGoogleId)
.devices()
.list()
.setCustomer("customers/my_customer")
.execute();
When I try to call the create endpoint I get a 403 Forbidden error. I want to know about what's the cause of this forbidden message and is there any way to fix it.
POST https://cloudidentity.googleapis.com/v1beta1/devices
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "The caller does not have permission",
"reason" : "forbidden"
} ],
"message" : "The caller does not have permission",
"status" : "PERMISSION_DENIED"
}
Thanks.