1

I have managed to create an enterprise, policy and setup a device using the 'Android Management API - Quickstart' document.

1) But I am having trouble moving forward. I want to be able to change the policy and not sure how to go about it. Is there a setup need to be done to send the policy update request?

2) I tried to get the policy from the browser using https://androidmanagement.googleapis.com/v1/enterprises/*/policies/* which is from the References page of Android Management API https://androidmanagement.googleapis.com/v1/{name=enterprises/*/policies/*} and the response that is

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

Any help will be appreciated

Cleaton Pais
  • 150
  • 1
  • 3
  • 13

3 Answers3

1

You can update the policy directly from the quickstart guide in the "Create a policy" section, the method for creating and updating a policy are the same.

Alternatively you can create a service account and call the API with a client library.

Fred
  • 2,191
  • 1
  • 12
  • 14
  • For now, I am updating the profile using the quickstart guide but I am in the process of switching the service account. I have created a service account and enabled the API in my project. Do you have a tutorial on how to use the client library – Cleaton Pais Dec 26 '19 at 05:31
0

1) I am currently using the same 'Android Management API - Quickstart' document to make changes in my policy but I am not sure if there is another method to accomplish the same thing

2) Not found a workaround the second issue

Cleaton Pais
  • 150
  • 1
  • 3
  • 13
0
  1. You can run/resend the whole policy or you can use updateMask
    https://developers.google.com/android/management/reference/rest/v1/enterprises.devices/patch

    Sample Code:
policy_json = '''
{
    "applications": [
    {
      "packageName": "com.android.chrome",
      "installType": "BLOCKED"
    },
    {
      "packageName": "com.evernote",
      "installType": "FORCE_INSTALLED"
    },
    {
      "packageName": "com.google.android.apps.docs.editors.docs",
      "installType": "FORCE_INSTALLED"
    }
],
   "factoryResetDisabled": false

}
'''

androidmanagement.enterprises().policies().patch(
    name=policy_name,
    updateMask="applications,factoryResetDisabled",
    body=json.loads(policy_json)
).execute()
  1. You can’t simply browse to the policy URL- the contents of the policy is private to your API client’s service account.
Deyzel
  • 186
  • 5