Google EMM API 烦恼

Google EMM API troubles

美好的一天! 我对 Google 玩 EMM

感兴趣

我已经创建了 Device Policy Controller 和 Work Profile。 创建了一个 Google Developers Console 项目并添加了 EMM API。 创建主服务帐户。 在主服务帐户中,我获得了 EMM 令牌。

我已经为 Java 下载了 Google Play EMM API 客户端库。 据我所知,我只需要调用

Enterprise enterprise = new Enterprise();
enterprise.setPrimaryDomain(primaryDomainName);
Enterprise result = androidEnterprise.enterprises()
   .enroll(authenticationToken, enterprise).execute();

EnterpriseAccount enterpriseAccount = new EnterpriseAccount();
enterpriseAccount.setAccountEmail(serviceAccountEmail);
androidEnterprise.enterprises().setAccount(result.getId(),
enterpriseAccount).execute();

第一个问题 - 如何以语法方式将设备(android phone) 添加到主服务帐户? 如果我在工作中使用 Google Android 并且默认使用 Google 系统 - 我会使用 "Device Enrollment" 应用程序。但我不知道如何以编程方式做到这一点。

第二个-样本中有这样的行

// Optional: you might want to store the bound enterprise's info, but
// these details can always be retrieved with an Enterprises.List call.

他们在哪里存储? 在 Google 个服务器上?当我认为当我做的时候我是对的吗 enterprise.setPrimaryDomain(主域名); 我可以访问所有已注册的客户吗?

第三 - 是否有正常样本?或者一步一步的howto?毕竟关于这一切的信息并不多( 谢谢。

你还有同样的问题吗?请让我知道我想我可以帮助您注册。

像这样更改请求:

Enterprise enterprise = new Enterprise();
enterprise.setPrimaryDomain(primaryDomainName);
enterprise.setId("Unique_EMM_ID"); //Which you will get from Google in mail
enterprise.setKind("androidenterprise#enterprise");

try{

      AndroidEnterprise.Enterprises.Enroll enroll = androidEnterprise.enterprises().enroll(authenticationToken, enterprise);
      enroll.setToken(token);

      Enterprise result = enroll.execute();

      EnterpriseAccount enterpriseAccount = new EnterpriseAccount();
      enterpriseAccount.setKind("androidenterprise#enterpriseAccount");
      enterpriseAccount.setAccountEmail(serviceAccountEmail);

      androidEnterprise.enterprises().setAccount(result.getId(), enterpriseAccount).execute();

   } catch (Exception e) {
        e.printStackTrace();
   }

这样试试。 希望对您有所帮助。

第一个问题的答案:

您可以从 https://admin.google.com/ 将设备添加到 MSA 1. 转到管理员 link 2. 在用户选项卡中添加一些用户。例如 - 你的名字@yourdomain.com 3. 从 Google Play 商店下载设备政策。 4. 添加您的用户电子邮件 ID,然后创建个人资料。 5. 这样你就可以将你的用户添加到管理员意味着 MSA。

希望对您有所帮助。 甚至您也可以从管理员为您的项目添加范围。如果您想了解更多信息,请告诉我。