![](/img/trans.png)
[英]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.