2

I'm trying to get person data using following .net(installed application) code. but it gives me error forbidden

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

I cannot even run the sample code here https://developers.google.com/+/domains/api/people/get#try-it it gives me following error

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"
 }
}

Note: I tried using website and installed application but both giving me same error.

Veedrac
  • 58,273
  • 15
  • 112
  • 169
Chamika Sandamal
  • 23,565
  • 5
  • 63
  • 86

0 Answers0