Google Admin SDK目录API调用挂起C#

时间:2015-08-28 15:02:42

标签: c# google-api-dotnet-client google-directory-api

我正在尝试获取我网域上的所有电子邮件。我在开发者控制台中设置了所有内容,并在管理控制台中为我的服务帐户提供了正确的访问权限。当它到达执行时它似乎挂起,它没有给出任何关于原因的指示。

这是我到目前为止所拥有的:

var certificate = new X509Certificate2(keyPathFile, "notasecret", X509KeyStorageFlags.Exportable);

ServiceAccountCredential credential = new ServiceAccountCredential(
     new ServiceAccountCredential.Initializer(serviceAccountEmail)
     {
          Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser },
          User = "admin_account@gmail.com"
     }.FromCertificate(certificate));

DirectoryService service = new DirectoryService(new BaseClientService.Initializer()
     {
          HttpClientInitializer = credential,
          ApplicationName = "app_name"
     });

var listReq = service.Users.List();
listReq.Domain = "domain";
Users allUsers = listReq.Execute();

关于可能出现什么问题的任何想法?谢谢。

0 个答案:

没有答案