Google.Apis.Requests.RequestError Insufficient Permission [403] Errors

3,005 views
Skip to first unread message

Maxsa Sidorov

unread,
Oct 27, 2014, 5:52:51 AM10/27/14
to adsen...@googlegroups.com
I write application in c# , which get list visits and click in google adsense. I try connect to google api. So maybe I don't correct initialize AdSenseService. This is my code:

            GoogleWebAuthorizationBroker.Folder = "AdSense.Sample";

            UserCredential credential;
            using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
            {
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    new[] { AdSenseHostService.Scope.Adsensehost },
                    "user", CancellationToken.None, new FileDataStore("AdSenseHostSampleStore")).Result;
            }

            // Create the service.
            var service = new AdSenseService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "AdSense Sample"
            });
           ........
            var accountRequest = service.Accounts.List();
            accountRequest.MaxResults = maxListPageSize;
            accountRequest.PageToken = pageToken;
            accountResponse = accountRequest.Execute();//Execption here


Error message:
Google.Apis.Requests.RequestError Insufficient Permission [403] Errors [Message[Insufficient Permission] Location[ - ] Reason[insufficientPermissions] Domain[global]]
 
So, how fix this error?

Jose Alcérreca (AdSense API Team)

unread,
Oct 27, 2014, 10:10:07 AM10/27/14
to adsen...@googlegroups.com
Hi there,

You are using the AdSense Host scope. Make sure you are executing the AdSense (Management) API samples.

Cheers,
Jose
Reply all
Reply to author
Forward
0 new messages