private ActionResult ConfigView(Settings settings, Config model) { // Grab all of the available sites that the authorized account has access to var authFactory = new GAuthSubRequestFactory("analytics", ApplicationName) { Token = settings.SessionToken }; var analytics = new AnalyticsService(authFactory.ApplicationName) { RequestFactory = authFactory }; foreach (AccountEntry entry in analytics.Query(new AccountQuery()).Entries) { var account = entry.Properties.First(x => x.Name == "ga:accountName").Value; if (!model.Sites.ContainsKey(account)) model.Sites.Add(account, new Dictionary<string, string>()); model.Sites[account].Add(entry.ProfileId.Value, entry.Title.Text); } return View("Config", model); }
public ActionResult AuthResponse(string token) { var sessionToken = AuthSubUtil.exchangeForSessionToken(token, null); Settings settings; using (RavenSession.Advanced.DocumentStore.DisableAggressiveCaching()) { settings = RavenSession.Load<Settings>(Settings.DefaultId); } if (settings == null) settings = new Settings { Id = Settings.DefaultId }; settings.SessionToken = sessionToken; RavenSession.Store(settings); return RedirectToAction("Config"); }