请求没有授权客户端 [英] Requested client not authorized
本文介绍了请求没有授权客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用谷歌服务帐户
我的域名获得谷歌的用户。
I am trying to get google users from my domain using google service account
.
但它会抛出错误
Error:"access_denied", Description:"Requested client not authorized.", Uri:""
我的code
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();
在此先感谢
推荐答案
服务帐户的电子邮件地址需要访问域。取邮件并将其添加为一个用户只需足够的访问,它可以阅读应该是不错的。
The service account email address needs to have access the domain. Take the email and add it as a user just enough access that it can read should be good.
另外你改变这种张贴?
Also did you change this for posting?
"publickey.gserviceaccount.com"
一个服务帐户的电子邮件看上去更像是这样的:
A service account email looks more like this:
539621478854-imkdv94bgujcom228h3ea33kmkoefhil@developer.gserviceaccount.com
这篇关于请求没有授权客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文