我正在尝试使用以下 .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- 它给了我以下错误
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"
}
}
注意:我尝试使用网站和安装的应用程序,但都给了我同样的错误。