简体   繁体   English

谷歌驱动器 API - 列出文件及其权限

[英]Google drive API - list files with its permissions

I want to list files and its permissions by this APIhttps://developers.google.com/drive/api/v3/reference/files/list我想通过这个 APIhttps://developers.google.com/drive/api/v3/reference/files/list列出文件及其权限

When I set fields to * or explicitly set当我将字段设置为*或明确设置时

  • files(id,name,description,mimeType,parents,trashed, permissions/*))文件(id,名称,描述,mimeType,父母,垃圾,权限/*))
  • files(id,name,description,mimeType,parents,trashed, permissions(*))文件(id,名称,描述,mimeType,父母,垃圾,权限(*))
  • files(id,name,description,mimeType,parents,trashed, permissions/emailAddress)文件(id、名称、描述、mimeType、父母、垃圾、权限/电子邮件地址)

I will never receive permissions.我永远不会获得许可。

I am getting this:我得到这个:

{
   "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 . 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 .

Here is what I call in "Try this API".这是我在“试用此 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

在此处输入图像描述

Do anyone know what is wrong?有谁知道出了什么问题?

Get all permissions获取所有权限

files(id,name,description,mimeType,parents,trashed,permissions)

Returns.返回。

 {
   "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
    }
   ]
  },

Just get the email permission只需获得 email 许可

files(id,name,description,mimeType,parents,trashed,permissions(emailAddress))

returns返回

 {
   "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"
    }
   ]
  },

It seems to work fine for me.这对我来说似乎工作得很好。

files(id, name, md5Checksum, size, parents, mimeType, webContentLink, permissionIds)文件(id、名称、md5Checksum、大小、父母、mimeType、webContentLink、permissionIds)

add "permissionIds" that between the returned data you will receive an array with the id of all permissions, in the case of files with "anyone" sharing the returned id is "anyoneWithLink"在返回的数据之间添加“permissionIds”,您将收到一个具有所有权限 id 的数组,如果文件与“anyone”共享返回的 id 是“anyoneWithLink”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM