Android Google Drive REST Api: List Files Return Empty Results (does not return all files)

April 13, 2019

When request google drive permission scope, DriveScopes.DRIVE_FILE only return files created/opened by the app. To return all files, use DriveScopes.DRIVE, DriveScopes.DRIVE_READONLY or DriveScopes.DRIVE_METADATA_READONLY

private fun buildGoogleSignInClient(): GoogleSignInClient {
    val signInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        // .requestScopes(Scope(DriveScopes.DRIVE_FILE))
        .requestScopes(Scope(DriveScopes.DRIVE))
        // .requestScopes(Scope(DriveScopes.DRIVE_METADATA_READONLY))
        .build()
    return GoogleSignIn.getClient(this, signInOptions)
}

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.