private async Task GetGoogleCalendarInternal() { try { if (SelectedProfile.GoogleSettings.GoogleAccount == null || SelectedProfile.GoogleSettings.GoogleAccount.Name == null) { return; } var calendars = await GoogleCalendarService.GetAvailableCalendars( SelectedProfile.GoogleSettings.GoogleAccount.Name); if (calendars.Any()) { if (SelectedProfile.GoogleSettings.GoogleCalendar != null) { SelectedProfile.GoogleSettings.GoogleCalendar = calendars.FirstOrDefault(t => t.Id.Equals(SelectedProfile.GoogleSettings.GoogleCalendar.Id)); } if (SelectedProfile.GoogleSettings.GoogleCalendar == null) { SelectedProfile.GoogleSettings.GoogleCalendar = calendars.First(); } } SelectedProfile.GoogleSettings.GoogleCalendars = calendars; } catch (Exception exception) { MessageService.ShowMessageAsync("Unable to get Google calendars."); Logger.Error(exception); } }
private void StartAuthentication(TaskScheduler taskScheduler) { //// Authenticate Oauth2 string clientId = "68932173233-e7nf2hlqhl9o16knj0iatg82bmgdkvom.apps.googleusercontent.com"; string clientSecret = "QRDGYelWPnCOsCiWlXVl6Cc3"; string redirectUri = "urn:ietf:wg:oauth:2.0:oob"; string userName = "******"; // A string used to identify a user (locally). var calenderService = (new AccountAuthentication()).AuthenticateCalenderOauth(clientId, clientSecret, userName, "OutlookGoogleSyncRefresh.Auth.Store", "OutlookGoogleSyncRefresh"); var googleCalenderService = new GoogleCalendarService(calenderService); googleCalenderService.GetAvailableCalendars() .ContinueWith(task => ContinuationActionGoogle(task, googleCalenderService, taskScheduler)); }
private void Button_Click_Selected(object sender, RoutedEventArgs e) { MyGrid.IsEnabled = false; //// Authenticate Oauth2 string clientId = "68932173233-e7nf2hlqhl9o16knj0iatg82bmgdkvom.apps.googleusercontent.com"; string clientSecret = "QRDGYelWPnCOsCiWlXVl6Cc3"; string redirectUri = "urn:ietf:wg:oauth:2.0:oob"; string userName = "******"; // A string used to identify a user (locally). var calenderService = (new AccountAuthenticationService(new ApplicationLogger(), new MessageService())).AuthenticateCalenderOauth(clientId, clientSecret, userName, "OutlookGoogleSyncRefresh.Auth.Store", "OutlookGoogleSyncRefresh"); var googleCalenderService = new GoogleCalendarService(calenderService, new ApplicationLogger()); var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); googleCalenderService.GetAvailableCalendars() .ContinueWith( task => GetInformation(task.Result, scheduler, googleCalenderService)); }