public async Task DefaultLocation() { const string key1 = "testkey1"; const string key2 = "testkey2"; var store = new FileDataStore("IntegrationTesting"); // Clear await store.ClearAsync(); // Check it's empty Assert.Null(await store.GetAsync <string>(key1)); Assert.Equal(0, await store.GetAsync <int>(key2)); // Add data await store.StoreAsync(key1, "1"); await store.StoreAsync(key2, 2); // Check data still there Assert.Equal("1", await store.GetAsync <string>(key1)); Assert.Equal(2, await store.GetAsync <int>(key2)); // Delete one item await store.DeleteAsync <string>(key1); // Check only that one item has gone Assert.Null(await store.GetAsync <string>(key1)); Assert.Equal(2, await store.GetAsync <int>(key2)); // Clear await store.ClearAsync(); // Check alldata has gone Assert.Null(await store.GetAsync <string>(key1)); Assert.Equal(0, await store.GetAsync <int>(key2)); }
/// <summary> /// Deletes the user from our datastore /// </summary> /// <param name="smartMirrorUsername">The custom username id to verify which user it is in our application</param> /// <returns></returns> public async Task LogoutGoogle(string smartMirrorUsername) { _currentUser = new GoogleUserModel(); var dataStore = new FileDataStore(DataStoreLocation); await dataStore.DeleteAsync<TokenResponse>(smartMirrorUsername); DeleteSpecificUserFromDb(smartMirrorUsername); }
public static async Task DeleteToken(FileDataStore datastore, string userid, CancellationToken cancellation) { cancellation.ThrowIfCancellationRequested(); if (datastore != null) { await datastore.DeleteAsync <AppTokenResult>(userid); } }
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(); } }
private void logout_btn_Click(object sender, EventArgs e) { if (listBox1.SelectedItems.Count != 0) { List <DriveInfo> dr = driveinfo.ToList(); foreach (var item in currentdriveinfo) { dr.Add(item); } for (int i = 0; i < driveinfo.Count; i++) { if (listBox1.SelectedItem.ToString().Contains(dr[i].UserID)) { listBox1.Items.RemoveAt(listBox1.SelectedIndex); datastore.DeleteAsync <Authentication.TokenResult>(dr[i].username); driveinfo.RemoveAt(i); MessageBox.Show("성공적으로 로그아웃 하였습니다"); logout = true; break; } } } }
UserCredential GetUserCredential(string ApplicationName, string ClientSecretPath, string[] scopes, bool recreateOAuthToken = false) { string exactPath = Path.GetFullPath(ClientSecretPath); string CredentialPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); CredentialPath = Path.Combine(CredentialPath, "driveApiCredentials", ApplicationName + "_drive-credentials.json"); FileDataStore filedataStore = new FileDataStore(CredentialPath, true); if (recreateOAuthToken) { filedataStore.DeleteAsync <TokenResponse>(Environment.UserName); } using (var stream = new FileStream(exactPath, FileMode.Open, FileAccess.Read)) { var authToken = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, scopes, Environment.UserName, CancellationToken.None, filedataStore).Result; return(authToken); } }
public static async Task DeleteToken(FileDataStore datastore, string userid, CancellationToken cancellation) { cancellation.ThrowIfCancellationRequested(); if (datastore != null) { await datastore.DeleteAsync<AppTokenResult>(userid); } }