I want any user to type his password and his e-mail, and select the file (access BD) in the program. Then press a button to upload the file to his account on google drive.
This is my code at the moment, this create a directory in my count:
UserCredential Credential;
Credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets { ClientId = "client_id", ClientSecret = "client_secret" },
new[] { DriveService.Scope.Drive, DriveService.Scope.DriveFile },
"user",
CancellationToken.None,
new FileDataStore("Drive.Auth.Store")).Result;
DriveService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = Credential,
ApplicationName = "Drive API hoteltactil",
});
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = "NewDirectory2";
body.Description = "Test Directory";
body.MimeType = "application/vnd.google-apps.folder";
body.Parents = new List<ParentReference>() { new ParentReference() { Id = "root" } };
try
{
FilesResource.InsertRequest request = service.Files.Insert(body);
request.Execute();
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
Console.Read();
}