New Google Drive Directory APIs error out: Bad request

早过忘川 提交于 2019-12-11 03:42:19

问题


I am using below piece of code to list all domain users in my simple Console application

        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() method errors out saying Bad Request.

Questions:

  1. How to overcome this issue?
  2. Does this Admin SDK support trial version of Google APP account?
  3. I have updated service account Client ID in Google Console and also updated in Admin Console with below scopes https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.user and also set API access check box. Do I missing something in settings?

回答1:


Like JoBe said, you should include the domain parameter.

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

This has worked for me.



来源:https://stackoverflow.com/questions/17750237/new-google-drive-directory-apis-error-out-bad-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!