/// <summary> /// Lists all accounts to which the user has access /// Documentation: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accounts/list /// </summary> /// <param name="service">Valid authenticated Analytics Service</param> /// <returns>List of Account resource - https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/accounts </returns> public static IList <Account> AccountList(AnalyticsService service) { //List all of the activities in the specified collection for the current user. // Documentation: https://developers.google.com/+/api/latest/activities/list ManagementResource.AccountsResource.ListRequest list = service.Management.Accounts.List(); list.MaxResults = 1000; // Maximum number of Accounts to return, per request. Accounts feed = list.Execute(); List <Account> resultList = new List <Account>(); //// Loop through until we arrive at an empty page while (feed.Items != null) { //Adding return items. resultList.AddRange(feed.Items); // We will know we are on the last page when the next page token is // null. // If this is the case, break. if (feed.NextLink == null) { break; } // Prepare the next page of results list.StartIndex = feed.StartIndex + list.MaxResults; // Execute and process the next page request feed = list.Execute(); } return(resultList); }
/// <summary> /// retrieves a list of the Google Analtyics accounts for the curently autenticated user. /// </summary> /// <param name="service">AnalyticsService</param> /// <returns></returns> public static Accounts Accountlist(AnalyticsService service) { ManagementResource.AccountsResource.ListRequest request = service.Management.Accounts.List(); Accounts result = request.Execute(); return(result); }
public async Task <ActionResult> AccountList() { service = new AnalyticsService(new BaseClientService.Initializer() { HttpClientInitializer = await GetCredentialForApiAsync(), ApplicationName = "Analytics API sample", }); //Account List ManagementResource.AccountsResource.ListRequest AccountListRequest = service.Management.Accounts.List(); //service.QuotaUser = "******"; Accounts AccountList = AccountListRequest.Execute(); return(View()); }