3

I want to list files and its permissions by this API https://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/*))
  • files(id,name,description,mimeType,parents,trashed, permissions(*))
  • files(id,name,description,mimeType,parents,trashed, permissions/emailAddress)

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.

Here is what I call in "Try this 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 

enter image description here

Do anyone know what is wrong?

1
  • If you are doing this with PHP you should include your code. Commented Feb 17, 2021 at 16:57

2 Answers 2

1

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": "[email protected]", "role": "owner", "displayName": "Linda Lawton", "photoLink": "https://lh3.googleusercontent.com/a-/AOh14GhroCYJp2P9xYeYk1npchBPK-zbtTxzNQo0WAHI20=s64", "deleted": false } ] }, 

Just get the email permission

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": "[email protected]" } ] }, 

It seems to work fine for me.

Sign up to request clarification or add additional context in comments.

11 Comments

For me not. Are you using any library? PHP?
As you have not include any code and appear to be making the calls directly i tested this in the try me section. THis is not an issue with the api its working as intended.
I added screenshot and CURL to the main post. I am trying it with PHP library and also directly in "Try this API". No one of them works as you mentioned.
My code is from the try me as well. It works fine. are you sure you have authorized the proper scopes`?
@MakoBuk Is it possible that you are in domain where there may be restricted access?
|
0

files(id, name, md5Checksum, size, parents, 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"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.