I am working on a .NET Google Drive app with scope drive.file. My app does not show up the list of shared files through the query Q = sharedWithMe. However, when I change my app's scope to drive the list of files appears. Why does it not work when the scope is set to drive.file? I created another project on Drive console and tested it but again it failed.
4 Answers
The Drive.Files scope states it only gives access to files opened or created by the app. The new API is more restrictive of file scope, I believe because Google is trying to push dev's to use the new google file picker (as a security measure), to get access to files not created by the app.
Your solutions are:
- use the Google file picker.
- use the previous api, and use a broader scope.
- share explicity with app (@pinoyyid answer), e.g. by creating an application owned account.
Update: I just tested, and can confirm your results. "Created by application" is not an attribute shared between accounts. It only affects the original account.
In my experience, drive.file scope permissions seem inconsistent.
For example (all actions are performed by the app with drive.file scope):
- userA creates a folderA (using files.insert)
- userA creates a file inside folderA called fileA (using /upload/drive/v2/files)
- userA shares folderA and fileA with userB (using permissions.insert)
- userB can see information about both folderA and fileA (using files.get) (So app on UserB account has access to both the folder and the file)
- if userA runs children.list on folderA or files.list with q:folderA in parents, it will show fileA
- if userB runs the same command it will not show fileA
I apologize for complexity of the above example, I can setup a simple javascript demo if that would be helpful.
I could not find anywhere in Google Drive documentation that claims any restrictions about accessing application created files on different accounts, so it might be a bug introduced trying to solve scope violation bugs last year.
For example: List ignores drive.file scope and shows shared files not created by the calling app