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

4

3 回答 3

1

您可以直接从“创建策略”部分的快速入门指南更新策略,创建和更新策略的方法相同。

或者,您可以创建一个服务帐户并使用客户端库调用 API 。

于 2019-12-23T15:38:21.037 回答
0

1) 我目前正在使用相同的“Android 管理 API - 快速入门”文档来更改我的策略,但我不确定是否有其他方法可以完成相同的事情

2)没有找到解决第二个问题的方法

于 2019-12-23T06:14:09.113 回答
0
  1. 您可以运行/重新发送整个策略,也可以使用 updateMask
    https://developers.google.com/android/management/reference/rest/v1/enterprises.devices/patch

    示例代码:
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. 您不能简单地浏览到策略 URL - 策略的内容对于您的 API 客户端的服务帐户是私有的。
于 2020-02-03T00:11:35.413 回答