MDM get Customers and Devices Api Access issue

balpreetsingh
Level 1.5: Cupcake

Can you please support for this issue. We have not been able to call the following api: We have executed all the steps mentioned in documents, still getting 403 GET https://androiddeviceprovisioning.googleapis.com/v1/partners/*****/customers { "code" : 403, "errors" : [ { "domain" : "global", "message" : "You are not allowed to retrieve the list of requested permission delegations.", "reason" : "forbidden" } ], "message" : "You are not allowed to retrieve the list of requested permission delegations.", "status" : "PERMISSION_DENIED", "details" : [ { "@type" : "type.googleapis.com/google.android.device.provisioning.v1.CustomError", "code" : "AUTHORIZATION_FAIL", "message" : "AUTHORIZATION_FAIL" } ] } To get the device listing for a customer we have followed below pre-requisites: A Google account, that's a member of your zero-touch enrollment reseller account. Java 1.7 or greater.(21) enable Android Device Provisioning Partner API. create a service account. Set Role to Service Accounts > Service Account User. Add key**, then click **Create new key* For **Key type**, select **JSON**. Click Create and the private key downloads to your computer. Move the Service account Json file to your working directory Linked service account to use the service account with your zero-touch enrollment account. Create a Java and Maven project with below dependencies: com.google.api-client google-api-client 1.31.1 com.google.auth google-auth-library-oauth2-http 1.30.1 com.google.oauth-client google-oauth-client-jetty 1.34.1 com.google.apis google-api-services-reseller v1-rev20230611-2.0.0 com.google.apis google-api-services-androiddeviceprovisioning v1-rev20220319-1.32.1 Tried to get the customer devices using suggested API: public void listDevicesForCustomer(String PARTNER_ID) { String parentId = "customers/" + PARTNER_ID; // Ensure correct format try { AndroidProvisioningPartner.Customers.Devices.List request = service.customers().devices().list(parentId); // Execute the request ListDevicesResponse response = request.execute(); // Process the response } catch (HttpResponseException e) { if (e.getStatusCode() == 403) { System.out.println("Access forbidden. Check permissions and customer ID."); } e.printStackTrace(); // Handle exception } catch (Exception e) { e.printStackTrace(); // Handle other exceptions } } Getting 403 GET https://androiddeviceprovisioning.googleapis.com/v1/customers/*344******/devices { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Insufficient Permission", "reason" : "insufficientPermissions" } ], "message" : "Request had insufficient authentication scopes.", "status" : "PERMISSION_DENIED", "details" : [ { "@type" : "type.googleapis.com/google.rpc.ErrorInfo", "reason" : "ACCESS_TOKEN_SCOPE_INSUFFICIENT", "domain" : "googleapis.com", "metadata" : { "method" : "google.android.device.provisioning.v1.customer.DeviceProvisioningCustomerService.ListDevices", "service" : "androiddeviceprovisioning.googleapis.com" } } ] } at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118) at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:428) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:514) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455) at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565) at com.airtel.africa.android_management.ResellerCustomers.main(ResellerCustomers.java:87) --

1 REPLY 1

Moombas
Level 4.1: Jelly Bean

To be honest, you should realign your post, it's not clearly where code starts or ends, where your own written tests starts/ends and where log entrys starting. I recommend to realign your post so it's easier to read.