public Drive(IUserCredentialApplication ucApp) { credential = DriveCredentialsService.GetUserCredential(ucApp); service = DriveCredentialsService.GetService(ucApp); application = ucApp; }
public static UserCredential GetUserCredential(IUserCredentialApplication ucApp) { GoogleWebAuthorizationBroker.Folder = "Drive.Sample"; UserCredential credential; using (var stream = ucApp.ClientJson) { var secrets = GoogleClientSecrets.Load(stream).Secrets; credential = GoogleWebAuthorizationBroker.AuthorizeAsync(secrets, new[] { DriveService.Scope.DriveFile, DriveService.Scope.Drive }, "user", CancellationToken.None).Result; } return(credential); }
public static DriveService GetService(IUserCredentialApplication ucApp) { return(GetService(GetUserCredential(ucApp), ucApp)); }