.net 未经授权的客户端或作用域Google网站管理员工具API

.net 未经授权的客户端或作用域Google网站管理员工具API,.net,api,google-webmaster-tools,.net,Api,Google Webmaster Tools,在过去的几天里,我遇到了一个问题,我似乎不是唯一遇到这个问题的人 我正试图通过谷歌NuGet提供的.NET库连接到谷歌网站管理员工具。我已经成功地在Google开发者控制台中创建了一个项目,生成了我的服务帐户并检索到了p12密钥 下一件事是在网站管理员工具中获取所有网站的列表,我通过以下方式完成: ... var result = webmasterService.Sites.List().Execute(); 在运行代码时,我遇到以下错误: Error:"unauthorized_clien

在过去的几天里,我遇到了一个问题,我似乎不是唯一遇到这个问题的人

我正试图通过谷歌NuGet提供的.NET库连接到谷歌网站管理员工具。我已经成功地在Google开发者控制台中创建了一个项目,生成了我的服务帐户并检索到了p12密钥

下一件事是在网站管理员工具中获取所有网站的列表,我通过以下方式完成:

...
var result = webmasterService.Sites.List().Execute();
在运行代码时,我遇到以下错误:

Error:"unauthorized_client", Description:"Unauthorized client or scope in request.", Uri:""
现在的问题似乎是我的客户无权访问网站管理员工具资源。过去几天我一直在浏览互联网寻求帮助,但我遇到了这个问题

我必须在何处指定此用户电子邮件以正确验证它

我的连接器代码如下所示:

string keyPath = Server.MapPath("/keys/webmastertoolsapi.p12");
const string serviceAccountEmail = "yadayada-123123@developer.gserviceaccount.com";
const string appName = "WebMasterToolsAPI";

var certificate = new X509Certificate2(keyPath,"notasecret",X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);

var credential = new ServiceAccountCredential(
    new ServiceAccountCredential.Initializer(serviceAccountEmail)
    {
        User = "name@domain.com", //email-account which has owner-rights in Webmaster Tools
        Scopes = new[] { WebmastersService.Scope.Webmasters }
    }.FromCertificate(certificate));

var webmasterService = new WebmastersService(new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = appName,
});

完全相同的问题。目前还不可能找到一种方法让它发挥作用。