Prabhat Subedi Prabhat Subedi - 1 month ago 5x
Java Question

Google Drive SDK API does not lists the file uploaded by Google Drive in java

I am creating an application which can insert files into Google Drive and lists it. I am using Google Drive SDK v2 API. But my problem is it is not listing files which is not uploaded through my application. If I upload directly from Google drive it is not listed in my application.

Here is the method to list the file:

private static List<File> retrieveAllFiles(Drive service) throws IOException {
List<File> result = new ArrayList<File>();
Files.List request = service.files().list();

do {
try {
FileList files = request.execute();

} catch (IOException e) {
System.out.println("An error occurred: " + e);
} while (request.getPageToken() != null &&
request.getPageToken().length() > 0);

return result;

and I am iterating files like this :

List<File> files = retrieveAllFiles(service);
for(File f : files) {
System.out.println("File Name : "+f.getOriginalFilename();

Can anyone help me please ? Thanks in advance ...


I think you are using the wrong oauth scope, probably which restrict your app's access to file created or opened by your app, when you should use which gives full control to your app.