【发布时间】: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() 方法错误提示错误请求。
问题:
- 如何解决这个问题?
- 此 Admin SDK 是否支持 Google APP 帐户的试用版?
- 我在 Google 控制台中更新了服务帐户客户端 ID,并在管理控制台中更新了以下范围 https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.user 并设置 API 访问复选框。我是否遗漏了设置中的某些内容?
【问题讨论】:
标签: google-admin-sdk