Guest User

Untitled

a guest
Jan 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. var provider = new WebServerClient(GoogleAuthenticationServer.Description)
  2. {
  3. ClientIdentifier = _appId,
  4. ClientSecret = _appSecret
  5. };
  6.  
  7. var auth = new OAuth2Authenticator<WebServerClient>(provider, x => new AuthorizationState { AccessToken = token });
  8. var analyticsService = new AnalyticsService(auth);
  9.  
  10. var accounts = analyticsService.Management.Accounts.List().Fetch();
  11.  
  12. foreach (var account in accounts.Items)
  13. {
  14. var webProperties = analyticsService.Management.Webproperties.List(account.Id).Fetch();
  15.  
  16. // todo: determine if web property is still in use?
  17. }
  18.  
  19. var provider = new WebServerClient(GoogleAuthenticationServer.Description)
  20. {
  21. ClientIdentifier = _appId,
  22. ClientSecret = _appSecret
  23. };
  24.  
  25. var auth = new OAuth2Authenticator<WebServerClient>(provider, x => new AuthorizationState { AccessToken = token });
  26. var analyticsService = new AnalyticsService(auth);
  27.  
  28. var accounts = analyticsService.Management.Accounts.List().Fetch();
  29. var result = new List<Profile>();
  30.  
  31. foreach (var account in accounts.Items)
  32. {
  33. var webProperties = analyticsService.Management.Webproperties.List(account.Id).Fetch();
  34.  
  35. foreach (var webProperty in webProperties.Items)
  36. {
  37. var profiles = analyticsService.Management.Profiles.List(account.Id, webProperty.Id).Fetch();
  38.  
  39. if (profiles.Items != null && profiles.Items.Any())
  40. {
  41. // these are the ones we want
  42. result.AddRange(profiles.Items);
  43. }
  44. }
  45.  
  46. }
  47. }
Add Comment
Please, Sign In to add comment