[英]How to get list of permissions of a folder/file with Google Drive API php
[英]Google drive API - list files with its permissions
我想通过这个 APIhttps://developers.google.com/drive/api/v3/reference/files/list列出文件及其权限
当我将字段设置为*或明确设置时
我永远不会获得许可。
我得到这个:
{
"id": "abc123"
"name": "Name of file",
"mimeType": "application/vnd.google-apps.folder",
"trashed": false,
"parents": [
"abc1234"
]
}
Also, I have noticed the API doesn't return NULL values (description), but the permission is not NULL when I fetch it by https://developers.google.com/drive/api/v3/reference/permissions/get .
这是我在“试用此 API”中所说的内容。
curl \
'https://www.googleapis.com/drive/v3/files?supportsAllDrives=true&fields=files(id%2Cname%2Cdescription%2CmimeType%2Cparents%2Ctrashed%2Cpermissions)&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
有谁知道出了什么问题?
获取所有权限
files(id,name,description,mimeType,parents,trashed,permissions)
返回。
{
"id": "1nsFyMDBDkeuLYx0oDIk9vQFOMH4Vc98ndxIG4Giq6Y",
"name": "Copy of How to create an credentails.json",
"mimeType": "application/vnd.google-apps.presentation",
"trashed": false,
"parents": [
"1dIyzPuh2XFVdlhJa4wSzNTlyCRguypI"
],
"permissions": [
{
"kind": "drive#permission",
"id": "0603058822553437243",
"type": "user",
"emailAddress": "me@gmail.com",
"role": "owner",
"displayName": "Linda Lawton",
"photoLink": "https://lh3.googleusercontent.com/a-/AOh14GhroCYJp2P9xYeYk1npchBPK-zbtTxzNQo0WAHI20=s64",
"deleted": false
}
]
},
只需获得 email 许可
files(id,name,description,mimeType,parents,trashed,permissions(emailAddress))
返回
{
"id": "1igmEhcgLrVFyneIcwFTetsFe-eDwKDsRqTmMwHaibs",
"name": "Copy of Copy of How to create an api key",
"mimeType": "application/vnd.google-apps.presentation",
"trashed": false,
"parents": [
"1yqppb5v5jSzCqnQaO8svooJh3C9nH3G"
],
"permissions": [
{
"emailAddress": "me@gmail.com"
}
]
},
这对我来说似乎工作得很好。
文件(id、名称、md5Checksum、大小、父母、mimeType、webContentLink、permissionIds)
在返回的数据之间添加“permissionIds”,您将收到一个具有所有权限 id 的数组,如果文件与“anyone”共享返回的 id 是“anyoneWithLink”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.