Google Drive API - Search only your own files

Today, when I tried to search all the files of a user in the domain, I found some files that have no parents. I figured out that those files are shared files from another users. So, to search all files that belong to me I 've just use the normal search function (here), and then remove files which have no parents out of the results:


def remove_no_parent_files(files):
    tmp = files
    for file in files:
        if not file['parents']:
            tmp.remove(file)
    return tm
p




Update 12/06/2013: Just verify this method, it's wrong (files of a shared folder has parents too). So, user 'owners' attribute instead to check the owners is the authenticated user:


def retrieve_own_files(service):
    tmp = []
    allfiles = search_files(service, "trashed = false")
    if allfiles:
        for file in allfiles:
            if file['owners'][0]['isAuthenticatedUser']:
                tmp.append()

    return tmp



This is how I solve the issue. Maybe there are many better ways out there, but for now, I just use it.

Comments