使用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
答案 0 :(得分:0)
以下是除了所有者之外的用户即使存在可共享链接也无法直接访问该文件的原因
要查看用户列表,请使用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":
}