【发布时间】:2019-10-09 21:10:43
【问题描述】:
您好朋友,我想在 Google 云端硬盘上上传图片、文件。所以我已经安装了Google.Apis.Auth 和Google.Apis.Drive.v3 nuget 包。
我还通过引用视频https://www.youtube.com/watch?v=xtqpWG5KDXYNow 创建了Client_secrete.json 文件。问题,如何使用这个Client_secrete.json 文件并从uwp 的Google Drive 中上传、下载、删除文件? :(
任何想法然后请分享代码或链接。
提前致谢:)...
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;
}
当我尝试运行此代码时,它会出错。 :(如何解决这个.....
【问题讨论】:
标签: xamarin.forms uwp win-universal-app uwp-xaml