/// <summary> /// Returns an active OneDriveApi instance. If a RefreshToken is available, it will set up an instance based on that, otherwise it will show the login dialog /// </summary> /// <param name="databaseConfig">Configuration of the KeePass database</param> /// <param name="oneDriveClientId">ClientID to get access to OneDrive</param> /// <param name="oneDriveClientSecret">ClientSecret to get access to OneDrive</param> /// <returns>Active OneDrive instance or NULL if unable to get an authenticated instance</returns> public static async Task<OneDriveApi> GetOneDriveApi(Configuration databaseConfig, string oneDriveClientId, string oneDriveClientSecret) { if (string.IsNullOrEmpty(databaseConfig.RefreshToken)) { var oneDriveAuthenticateForm = new OneDriveAuthenticateForm(oneDriveClientId, oneDriveClientSecret); var result = oneDriveAuthenticateForm.ShowDialog(); if (result != DialogResult.OK) { return null; } // Save the configuration so we keep the Refresh Token var oneDriveApi = oneDriveAuthenticateForm.OneDriveApi; databaseConfig.RefreshToken = oneDriveApi.AccessToken.RefreshToken; Configuration.Save(); return oneDriveApi; } try { return await OneDriveApi.GetOneDriveApiFromRefreshToken(oneDriveClientId, oneDriveClientSecret, databaseConfig.RefreshToken); } catch (WebException) { // Occurs if no connection can be made with the OneDrive service. It will be handled properly in the calling code. return null; } }
public OneDriveCloudTypeForm(Configuration configuration) { InitializeComponent(); OneDriveConsumerPicture.Image = Resources.OneDriveConsumer; OneDriveForBusinessPicture.Image = Resources.OneDriveForBusiness; _configuration = configuration; }
/// <summary> /// Returns an active OneDriveApi instance. If a RefreshToken is available, it will set up an instance based on that, otherwise it will show the login dialog /// </summary> /// <param name="databaseConfig">Configuration of the KeePass database</param> /// <param name="oneDriveClientId">ClientID to get access to OneDrive</param> /// <param name="oneDriveClientSecret">ClientSecret to get access to OneDrive</param> /// <returns>Active OneDrive instance or NULL if unable to get an authenticated instance</returns> public static async Task<OneDriveApi> GetOneDriveApi(Configuration databaseConfig, string oneDriveClientId, string oneDriveClientSecret) { if (string.IsNullOrEmpty(databaseConfig.RefreshToken)) { var oneDriveAuthenticateForm = new OneDriveAuthenticateForm(oneDriveClientId, oneDriveClientSecret); var result = oneDriveAuthenticateForm.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) { return null; } // Check if we already know where to store the Refresh Token for this database if (!databaseConfig.RefreshTokenStorage.HasValue) { // We don't know yet where the Refresh Token for this database should be stored, ask the user to choose var oneDriveRefreshTokenStorageForm = new OneDriveRefreshTokenStorageDialog(databaseConfig); oneDriveRefreshTokenStorageForm.ShowDialog(); } // Save the configuration so we keep the Refresh Token var oneDriveApi = oneDriveAuthenticateForm.OneDriveApi; databaseConfig.RefreshToken = oneDriveApi.AccessToken.RefreshToken; Configuration.Save(); return oneDriveApi; } try { var oneDriveApi = new OneDriveApi(oneDriveClientId, oneDriveClientSecret); ApplyProxySettings(oneDriveApi); await oneDriveApi.AuthenticateUsingRefreshToken(databaseConfig.RefreshToken); return oneDriveApi; } catch (WebException) { // Occurs if no connection can be made with the OneDrive service. It will be handled properly in the calling code. return null; } }
public OneDriveAskToStartSyncingDialog(Configuration configuration) { InitializeComponent(); _configuration = configuration; }
public OneDriveRefreshTokenStorageDialog(Configuration configuration) { InitializeComponent(); _configuration = configuration; }
public OneDriveRemoteLocationDialog(Configuration databasecConfiguration) { InitializeComponent(); _databaseConfiguration = databasecConfiguration; }