新的Google Drive Directory API错误:请求错误 [英] New Google Drive Directory APIs error out: Bad request
本文介绍了新的Google Drive Directory API错误:请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用下面的代码来列出我的简单控制台应用程序中的所有域用户
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()方法出错,提示错误请求.
Execute() method errors out saying Bad Request.
问题:
- 如何克服这个问题?
- 此管理SDK是否支持Google APP帐户的试用版?
- 我已经在Google控制台中更新了服务帐户客户端ID,并且还在管理控制台中更新了以下范围 https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.user 并设置API访问权限复选框.我是否在设置中缺少某些内容?
- How to overcome this issue?
- Does this Admin SDK support trial version of Google APP account?
- 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?
推荐答案
就像JoBe所说的那样,您应该包括domain参数.
Like JoBe said, you should include the domain parameter.
happy_user = service.users().list(domain ='mydomain.com').execute()
happy_user = service.users().list(domain='mydomain.com').execute()
这对我有用.
这篇关于新的Google Drive Directory API错误:请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文