检索.NET应用程序中的所有移动设备Google Directory API

时间:2015-09-24 05:11:07

标签: c# google-api google-admin-sdk google-api-dotnet-client

我想在我的appilcation中使用Google API管理设备。如何检索所有移动/ Chrome操作系统设备?

代码:

var listReq1 = service.Mobiledevices.List(serviceAccountEmail);
 MobileDevices allUsers = listReq1.Execute(); 

在这里,

  

serviceAccountEmail =" 服务帐户密钥" (Console.developer.google.com)

我收到错误

Google.Apis.Requests.RequestError
Bad Request [400] 

我尝试使用

var listReq= new Google.Apis.Admin.Directory.directory_v1.MobiledevicesResource.ListRequest(service,serviceAccountEmail);

仍然无法使用?我想要User的所有细节就像下面的图像

enter image description here

1 个答案:

答案 0 :(得分:0)

如果您查看Mobiledevices: list

的文档
  

检索 帐户的所有移动设备的分页列表。

我会看到它需要客户ID作为parmater。

  

customerId
客户Google帐户的唯一ID。如   如果是帐户管理员,您还可以使用my_customer别名   代表您帐户的customerId。 customerId也会被退回   作为用户资源的一部分。

var listReq1 = service.Mobiledevices.List(customerId);
MobileDevices allUsers = listReq1.Execute(); 

您正在发送服务帐户的电子邮件地址,我认为这不是您的客户ID。