谷歌驱动器中共享文件所需的自动化
问题描述:
借助Google Drive for VB.Net,我设法获得了与其他人的可共享链接,但是当该人尝试打开文件或将链接放入地址栏时,出现错误发生“授权要求”。谷歌驱动器中共享文件所需的自动化
这里是我的代码:
Dim list = Service.Files.List()
Dim count = list.Execute()
For Each fich In count.Items
If (fich.Title) = fichier Then
fich.Shared = True
Dim userpermit = New Permission()
userpermit.Type = "user"
userpermit.Role = "Reader"
userpermit.Value = "*********"
userpermit.EmailAddress = "*******"
userpermit.WithLink = True
listfile.adr_mail.Text = fich.AlternateLink ' to Get a shareable link
Dim req = Service.Permissions.Insert(userpermit, fich.Id)
req.Fields = "id"
Exit For
End If
Next
答
这里是为什么即使有一个分享的链接除了所有者的用户不能直接访问该文件的原因,
- 该文件可能是私人(为货主只)
- 试图打开该文件的用户可能不是授权用户的列表
要查看用户列表,请使用Try it now部件。您需要提供fileId
。
GET https://www.googleapis.com/drive/v2/files/fileId/permissions
,你会得到回应是这样的:
{
"kind": "",
"etag": "",
"id": "",
"selfLink": "",
"name": "",
"emailAddress": "@something.com",
"domain": "something.com",
"role": "owner",
"type": "user",
"deleted":
}
我忘记.execute()在insert权限和我改变阅读器读者..和它的工作 –