Issues accessing root folder files in Google Drive

I’m trying to make an app that can see all the files in the main Google Drive folder. The problem is I can only set permissions for making and looking at files. But I need to look at files I put in Google Drive using the regular website. How can I do this?

Here’s some code I’m using:

@Override
protected void onRestart() {
    super.onRestart();
    if (driveConnector == null) {
        driveConnector = new DriveConnector.Builder(this)
                .addApi(CloudStorage.API)
                .addScope(CloudStorage.SCOPE_DOCUMENT)
                .addScope(CloudStorage.SCOPE_APPDATA)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }

    driveConnector.connect();
}

Can anyone help me figure out how to access those files I uploaded through the browser? Thanks!

I encountered a similar issue while developing a Drive integration. The solution lies in the scopes you’re requesting. The SCOPE_DOCUMENT and SCOPE_APPDATA are too restrictive for what you’re trying to achieve.

To access files in the root folder, including those uploaded via the web interface, you need to use the SCOPE_FILE scope. This grants broader access to the user’s Drive contents.

Modify your code to include:

.addScope(CloudStorage.SCOPE_FILE)

Also, ensure you’re using the latest Google Drive API version. Older versions often have more limitations on file access.

Remember to clearly explain to users why your app needs this level of access. Transparency helps in getting permissions approved. Best of luck with your development!

I’ve run into this issue before when developing Drive-integrated apps. The key is to request the right scopes. From your code, I see you’re using SCOPE_DOCUMENT and SCOPE_APPDATA, but these are limited.

To access files in the root folder that weren’t created by your app, you need to use the SCOPE_FILE scope instead. This gives broader access to the user’s Drive contents.

Try modifying your code like this:

.addScope(CloudStorage.SCOPE_FILE)

Also, make sure you’re using the latest version of the Google Drive API. Older versions had more restrictions on file access.

Remember to clearly communicate to users what your app will access and why. Users are more likely to grant permissions if they understand the purpose. Good luck with your app development!

hey mate, hav u tried using the SCOPE_DRIVE scope? its broader than SCOPE_FILE and might solve ur problem. just add this line:

.addScope(Drive.SCOPE_DRIVE)

it’ll give u full access to everything in Drive. just remember to tell users why u need this access, they mite freak out otherwise lol. good luck with ur app!