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.....