Listing Drive folders through Apps Scripts doesn’t show permissions

Objective: To list all the folders in the Drive of an organization and all the people with access to each folder.

I’m doing it through Apps Scripts with the advanced Drive service enabled.

function listFolders() {
    var query = 'mimeType = "application/" and trashed = false'
    var response = Drive.Files.list({corpora: 'domain', q : query});
    if (response.items && response.items.length > 0) {
        var foldersDetails = getFoldersDetails(response.items);

function getFoldersDetails(items) {
    var foldersArr = [];
    for (var i = 0; i < items.length; i++) {
        var folderDetails = getFolderDetails(items[i].id);
    return foldersArr;

function getFolderDetails(fileId) {
    var file = Drive.Files.get(fileId);
    return {name: file.title,
            permissions: file.permissions}

The problem is that I’m just getting nulls instead of permission objects.

The Drive API docs:

What am I doing wrong?


This is due to partial response However.

Files list will only return the id and name I believe the documentation is old and invalid if i recall. On the other hand File.get you can add add the fields parameter and use * it will then return all the parameters that you are now seeing returned as null

I am not a JavaScript or app script developer. The code should be something like this only work with file get. I cant seem to find an example for it only one for using files.list which doesn’t work with V3.

function listFiles() {
  var files = Drive.Files.list({
    fields: 'nextPageToken, items(id, title)',
    maxResults: 10
  for (var i = 0; i < files.length; i++) {
    var file = files[i];
    Logger.log('%s (%s)', file.title,;

if you want to see everything use *

var files = Drive.Files.list({
    fields: '*',
    maxResults: 10

Links to How to get full file response

Leave a Reply

Your email address will not be published. Required fields are marked *