/// <summary> /// Authenticates a client using browser consent form, may require login and password for Google account. /// </summary> /// <param name="cancellationToken">Token that allows to cancel authentication task.</param> /// <param name="secrets">A set of client secrets to use when authenticating.</param> /// <param name="scopes">A set of capabilities to request from Google services.</param> /// <param name="log">Logger that accepts debug info.</param> /// <param name="dataStoreName">Name of a file data store to use to store credentials.</param> /// <returns>Refresh token.</returns> /// <exception cref="OperationCanceledException">Operation was cancelled by user.</exception> public static async Task <string> AuthenticateManually( CancellationToken cancellationToken, ClientSecrets secrets, IEnumerable <string> scopes, IIoLogger log, string dataStoreName) { try { var dataStore = new DummyDataStore(); var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( secrets, scopes, "user", cancellationToken, dataStore); log.LogMessage("Successfully authenticated"); return(credential.Token.RefreshToken); } catch (Exception e) { if (e is OperationCanceledException) { throw (OperationCanceledException)e; } log.LogError("Authentication error", e); throw; } }
/// <inheritdoc /> protected override void UpdateLog(IIoLogger logger) { lock (this) { foreach (var task in this.childTasks) { task.Log = logger; } } }
/// <summary> /// Authenticates a client using browser consent form, may require login and password for Google account. /// </summary> /// <param name="cancellationToken">Token that allows to cancel authentication task.</param> /// <param name="log">Logger object used to output debug info.</param> /// <returns>Refresh token.</returns> /// <exception cref="OperationCanceledException">Operation was cancelled by user.</exception> public static async Task <string> AuthenticateManually(CancellationToken cancellationToken, IIoLogger log) { log.LogMessage("Authorizing manually for Google Drive as Google Drive Sync"); string[] scopes = { DriveService.Scope.DriveReadonly }; var secrets = new ClientSecrets { ClientId = Constants.GoogleDriveSyncClientId, ClientSecret = Constants.GoogleDriveSyncClientSecret }; return(await ManualAuthenticator.AuthenticateManually( cancellationToken, secrets, scopes, log, "GoogleDrive_Datastore")); }
public TaskContext(IIoLogger log, CancellationToken cancellationToken, TaskStatusAccumulator statusAccumulator) { this.Log = log; this.CancellationToken = cancellationToken; this.statusAccumulator = statusAccumulator; }
/// <summary> /// Virtual method that is called when Log property changes and shall be overriden to propagate log changing. /// </summary> /// <param name="logger">New logger object.</param> protected virtual void UpdateLog(IIoLogger logger) { }