【问题标题】:New Google Drive Directory APIs error out: Bad request新的 Google Drive Directory API 错误:错误请求
【发布时间】:2013-07-18 23:36:57
【问题描述】:

我正在使用下面的代码在我的简单控制台应用程序中列出所有域用户

        var certificate = new X509Certificate2("D:\\3acf2c2008cecd33b43de27e30016a72e1482c41-privatekey.p12", "notasecret", X509KeyStorageFlags.Exportable);

        var privateKey = certificate.Export(X509ContentType.Cert);
        var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate)
        {
            ServiceAccountId = "877926787679-b7fd15en1sh2oc65e164v90cfcvrfftq@developer.gserviceaccount.com",
            Scope = DirectoryService.Scopes.AdminDirectoryUserReadonly.GetStringValue(),
            ServiceAccountUser = "user1@05.mygbiz.com"
        };

        var auth = new OAuth2Authenticator<AssertionFlowClient>(provider, AssertionFlowClient.GetState);

        DirectoryService dirService = new DirectoryService(new BaseClientService.Initializer()
        {
            Authenticator = auth,
            ApplicationName = "My APP"
        });
        Users users = dirService.Users.List().Execute();

Execute() 方法错误提示错误请求。

问题:

  1. 如何解决这个问题?
  2. 此 Admin SDK 是否支持 Google APP 帐户的试用版?
  3. 我在 Google 控制台中更新了服务帐户客户端 ID,并在管理控制台中更新了以下范围 https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.user 并设置 API 访问复选框。我是否遗漏了设置中的某些内容?

【问题讨论】:

    标签: google-admin-sdk


    【解决方案1】:

    就像 JoBe 说的,你应该包含 domain 参数。

    happy_user = service.users().list(domain='mydomain.com').execute()

    这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多