c# 4.0 - Why am I unable to list all my accounts with this code? -
this first foray google analytics. created service account , downloaded p12 file developer console. code works, in incomplete way.
i have 2 accounts, code below returns 1 account list. how accounts listed?
private static serviceaccountcredential run2() { const string keyfilepath = "file.p12"; const string serviceaccountmail = "notarealemailaddress@developer.gserviceaccount.com"; var certificate = new x509certificate2(keyfilepath, "notasecret", x509keystorageflags.exportable); var credential = new serviceaccountcredential(new serviceaccountcredential.initializer(serviceaccountmail) { scopes = new[] { analyticsservice.scope.analytics, analyticsservice.scope.analyticsreadonly, analyticsservice.scope.analyticsprovision } }.fromcertificate(certificate)); return credential; } static void main() { var cr = run2(); var service = new analyticsservice(new baseclientservice.initializer() { httpclientinitializer = cr, applicationname = "analytics api sample" }); var request = service.management.accounts.list(); request.maxresults = 20; var result = request.execute(); foreach (var item in result.items) { console.writeline("account name: {0} {1} {2}", item.name, item.kind, item.id); } }
this ended doing. service account google creates needs added every account need access. figured reading documentation.
https://developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/service-py
Comments
Post a Comment