问题
Hello friend I want to upload an images,files on Google Drive. So I have installed the Google.Apis.Auth
and Google.Apis.Drive.v3
nuget packages.
I have also created the Client_secrete.json
file by referring video https://www.youtube.com/watch?v=xtqpWG5KDXYNow
. Question, how to use this Client_secrete.json
file and upload, download, delete the files from the Google Drive in uwp
? :(
Any idea then please share code or link.
Thanks in advance :)...
public static DriveService GetService()
{
UserCredential credential;
DriveService service = new DriveService();
using (var stream = new FileStream(destinationFolder.Path + @"\client_secret.json", FileMode.Open, FileAccess.Read))
{
String FolderPath = destinationFolder.Path;
String FilePath = Path.Combine(FolderPath,
"DriveServiceCredentials.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"users",
CancellationToken.None,
new FileDataStore(FilePath, true)).Result; // Here i got
the exception.
service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "DemoDrive",
});
}
return service;
}
When i am trying to run this code it gives error. :( how to solve this.....
回答1:
Please check Google.Apis.Drive.v3, the nuget package incompatible platform contain uwp and Xamarin. So, you could not use it for xamarin.uwp app. For cloud drive within uwp platform, we suggest you use OneDrive to replace. And we have provide OneDrive Service api that could implement cloud drive immediately.
来源:https://stackoverflow.com/questions/56272752/xamarin-form-how-to-upload-delete-download-files-from-google-drive-in-uwp