public static FileDataStore GetFileDataStore() { var path = HttpContext.Current.Server.MapPath("~/App_Data/Drive.Api.Auth.Store"); FileDataStore fileDataStore=new FileDataStore(path); fileDataStore.ClearAsync(); return fileDataStore; }
public static async Task ClearToken(FileDataStore datastore, CancellationToken cancellation) { cancellation.ThrowIfCancellationRequested(); if (datastore != null) { await datastore.ClearAsync(); } }
public static bool SetUserCredentials(bool force) { try { OnStartingAuth(); var fileDataStore = new FileDataStore("GMinder.Auth.Store"); if (force) { Properties.Settings.Default.LoggedIn = false; Properties.Settings.Default.Save(); fileDataStore.ClearAsync().Wait(); } var authorizeTask = GoogleWebAuthorizationBroker.AuthorizeAsync( GMinderClientSecrets.getSecret(), new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None, fileDataStore); Task.WaitAny(new Task[] { authorizeTask }, 60000); if (!authorizeTask.IsCompleted) { authorizeTask.Dispose(); throw new Exception("Failed to get authorization within 1 minute"); } UserCredential credential = authorizeTask.Result; _Service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "GMinder", }); Properties.Settings.Default.LoggedIn = true; Properties.Settings.Default.Save(); return(true); } catch (Exception e) { MessageBox.Show( "Can not access your Google Calendar account. Make sure you accept when asked to authorize GMinder.", "Can't access Google Calendar account", System.Windows.Forms.MessageBoxButtons.OK ); Logging.LogException(false, e, "Unknown Error: " + e.Message); return(false); } finally { OnEndingAuth(); } }
public void PurgeSettings(RootName root) { var dataStore = new FileDataStore(GoogleWebAuthorizationBroker.Folder, false); if (root != null) { dataStore.DeleteAsync <TokenResponse>(root.UserName).Wait(); } else { dataStore.ClearAsync().Wait(); } }
//hplLogout_Click private void hplLogout_Click(object sender, RoutedEventArgs e) { try { ModernDialog md = new ModernDialog(); md.Buttons = new Button[] { md.YesButton, md.CloseButton, }; md.Title = FindResource("notification").ToString(); md.Content = FindResource("are_you_sure_logout").ToString(); md.YesButton.Content = FindResource("yes").ToString(); md.CloseButton.Content = FindResource("no").ToString(); md.YesButton.Focus(); bool result = md.ShowDialog().Value; if (result == true) { FileDataStore filedatastore_store = new FileDataStore("TuanNguyen.GoogleDrive.Auth.Store"); filedatastore_store.ClearAsync(); //set email textblock this.tblEmailAddress.Text = ""; this.tblEmailAddress.Visibility = System.Windows.Visibility.Hidden; //set login logout this.tblLogout.Visibility = System.Windows.Visibility.Hidden; this.tblLogin.Visibility = System.Windows.Visibility.Visible; //set null list_tb_database.Clear(); dtgDatabase.ItemsSource = null; this.tblTotal.Text = FindResource("checkout_zero").ToString(); this.muiBtnBackup.Visibility = System.Windows.Visibility.Hidden; } } catch (Exception ex) { ModernDialog md = new ModernDialog(); md.Title = FindResource("notification").ToString(); md.Content = ex.Message; md.ShowDialog(); } }
public void Clear() { var t = _store.ClearAsync(); t.Wait(); }
public static async Task ClearToken(FileDataStore datastore, CancellationToken cancellation) { cancellation.ThrowIfCancellationRequested(); if (datastore != null) { await datastore.ClearAsync(); } }
private void linkLabelRevokeAuthentication_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { Logger.Log("Trying to remove Authentication...", EventType.Information); FileDataStore fDS = new FileDataStore(Logger.AuthFolder, true); fDS.ClearAsync(); Logger.Log("Removed Authentication...", EventType.Information); } catch (Exception ex) { Logger.Log(ex.ToString(), EventType.Error); } }