Justin Justin - 3 months ago 27
iOS Question

iOS Google Drive SDK - Query string for folders doesn't appear to be working

Per GTLQueryDrive.h method documentation:

// Method: drive.files.list
// Lists the user's files.
// Optional:
// q: Query string for searching files.
// Fetches a GTLDriveFileList.
+ (id)queryForFilesList;

Also here: https://developers.google.com/drive/search-parameters
Second item under the Examples heading:

Search for folders using the folder-specific MIME type
mimeType = 'application/vnd.google-apps.folder'

When I perform a
and set
, I get a non-error result but the contents of the GTLFileList only has two properties set,
. There is nothing else returned in the results. See below:

GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];

query.q = @"mimeType='application/vnd.google-apps.folder'";

[self.fileChecker executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {

if (!error) {
//I see this in the console...
//No Errors in Folder Query:
//GTLDriveFileList 0x108f3430: {kind:"drive#fileList"
NSLog(@"No Errors in Folder Query: %@",object);

GTLDriveFileList *list = (GTLDriveFileList *)object;

//So, none of this for() loop happens
for (GTLDriveFile *file in list.items) {
NSLog(@"Folder: \n \n %@ \n \n",file);
} else {
NSLog(@"Folder Query Error: %@",error);

Anything I'm doing wrong? The iOS Google Drive app can definitely find a list of Folders. What am I doing wrong?


My code is correct. I was using the wrong permissions when accessing Google Drive. I changed it from kGTLAuthScopeDriveFile (which only shows you files and folders you created with your app) to kGTLAuthSchopeDrive (which will show you content created on the site and other apps)

You use this constant when signing in to Google Drive and presenting the GTMOAuth2ViewControllerTouch xib file.