【发布时间】:2020-06-26 07:04:29
【问题描述】:
我正在尝试为 Google 共享驱动器上的某些网站创建外部快捷方式。有文档:https://developers.google.com/drive/api/v3/third-party-shortcuts 但我不知道如何将 URL 传递到我想要的页面。
var credential = GoogleCredential.FromJson(jsonSecret)
.CreateScoped(Scopes)
.CreateWithUser("myemail@company.com")
.UnderlyingCredential as ServiceAccountCredential;
DriveService _driveService = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "to-teamdrive"
});
var fileMetadata = new File()
{
Name = "Test shortcut",
MimeType = "application/vnd.google-apps.drive-sdk",
Parents = new List<string> { "0AKSia6LzF-hvuk9PVA"}
};
var uploadRequest = _driveService.Files.Create(fileMetadata);
uploadRequest.SupportsAllDrives = true;
uploadRequest.Fields = "id";
var file = uploadRequest.Execute();
此外,执行此代码会抛出:
Message="与此快捷方式文件关联的应用程序不支持共享驱动器。"
跳过父母属性时,我可以在我的驱动器中创建一个“链接”,但即便如此我也不知道如何将 URL 添加到此“链接”。它会在我的驱动器上创建空...文件...。
【问题讨论】:
-
shared drive is gsuite 是您作为 gsuite 域的一部分登录的用户吗?
-
我想是的...我是公司的一名员工,拥有公司的电子邮件和 Google 服务的访问权限。但是,我不能自己创建共享驱动程序。我只能访问它们。我还可以从浏览器手动创建外部快捷方式。但是我使用以下内容登录: var credential = GoogleCredential.FromJson(jsonSecret) .CreateScoped(Scopes) .CreateWithUser("mylogin@company.com") .UnderlyingCredential as ServiceAccountCredential;
-
我尝试访问admin.google.com,它说只有 GSuite 帐户可以访问此 URL,而我的是标准帐户。
-
正是您需要使用 gsuite 帐户才能访问该功能。
-
uploadRequest.SupportsAllDrives = true;
标签: c# google-api google-drive-api google-api-dotnet-client