如何在.Net应用程序中使用google domains apis

时间:2014-09-25 14:29:38

标签: c# google-api-dotnet-client google-domain-api

我正在尝试使用以下.net(已安装的应用程序)代码获取人员数据。但它给了我错误禁止

UserCredential credential;
using (var stream = new FileStream("path to the secrets json", FileMode.Open, FileAccess.Read))
{
    credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
        GoogleClientSecrets.Load(stream).Secrets,
        new[] { 
            PlusDomainsService.Scope.PlusCirclesRead,
            PlusDomainsService.Scope.PlusCirclesWrite,
            PlusDomainsService.Scope.PlusLogin,
            PlusDomainsService.Scope.PlusMe,
            PlusDomainsService.Scope.PlusMediaUpload,
            PlusDomainsService.Scope.PlusProfilesRead,
            PlusDomainsService.Scope.PlusStreamRead,
            PlusDomainsService.Scope.PlusStreamWrite,
            PlusDomainsService.Scope.UserinfoEmail,
            PlusDomainsService.Scope.UserinfoProfile
        },
        "user", CancellationToken.None, new FileDataStore("Domains.SampleApi"));
}

var service = new PlusDomainsService(new BaseClientService.Initializer
{
    ApplicationName = "API Sample",
    HttpClientInitializer = credential
});
var me = await service.People.Get("me").ExecuteAsync();<-- this line gives error

我甚至无法在此处运行示例代码 https://developers.google.com/+/domains/api/people/get#try-it 它给了我以下错误

Cache-Control:  private, max-age=0
Content-Type:  application/json; charset=UTF-8
Date:  Thu, 25 Sep 2014 14:24:56 GMT
Expires:  Thu, 25 Sep 2014 14:24:56 GMT
Server:  GSE
Transfer-Encoding:  chunked

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "Forbidden"
   }
  ],
  "code": 403,
  "message": "Forbidden"
 }
}

注意:我尝试使用网站和安装的应用程序,但都给了我同样的错误。

0 个答案:

没有答案