【发布时间】:2014-05-27 11:30:38
【问题描述】:
我正在尝试使用 google service account 从我的域中获取 google 用户。
但是会报错
Error:"access_denied", Description:"Requested client not authorized.", Uri:""
我的代码
X509Certificate2 certificate = new X509Certificate2(key_path,
"notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer("publickey.gserviceaccount.com")
{ Scopes = scopes,
User = "admin@domain.com"
}.FromCertificate(certificate));
var service = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "appname",
});
service.Users.List().Domain = "domain.com";
Users results = service.Users.List().Execute();
提前致谢
【问题讨论】:
-
你已经尝试过什么?很多事情都可能出错,证书、证书的安装、您使用的用户等等......
标签: c# asp.net google-app-engine google-api google-apps