This code runs fine with the scope "https://www.googleapis.com/auth/drive"
File folderEntry = drive.files().get("XXXXj0_srDPPGUEtHaVYtZFljMEk").execute();
String driveQuery = "title = '" + "test" + "' and mimeType = 'application/vnd.google-apps.folder' and ";
driveQuery += "'" + folderEntry.getId() + "' in parents";
Files.List request = drive.files().list();
request.setQ(driveQuery);
FileList files = request.execute();
But if I change the scope to "https://www.googleapis.com/auth/drive.file" in the credentials, and in the API Client access panel, an error 500 is thrown.
500 Internal Server Error { "code" : 500, "errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError" } ], "message" : "Internal Error" }
I am using a service account and the parent folder was created by the application.
I do not understand why I cannot perform this query.
This may be a bit late but... I believe the problem occurs because when you run with the scope https://www.googleapis.com/auth/drive.file you are only allowed to see the files your app has created. However, your query may potentially return metadata that are outside your auth scope.
I had the same problem as well and manage to fix it by adding the DRIVE_METADATA_READONLY scope:
I too get the same error. However this workaround does get all the children of a folder I created, until google fixes the query issue I suppose.