I'm trying to retrieve all Google Drive files that where created by users within my organisation (Domain-wide delegation and the drive role are set).
srv.Files.List().Corpora("domain").Fields("*").Q(modifiedTime).PageSize(1000).Pages(d.ctx, listFiles)
Although, the result of such call, only returns the files that have the "People in [COMPANY] can search for this file" in the share settings, toggled.
If I impersonate a different user and change the Corpora("domain")
to Corpora("user")
I can list all files, but that's not optimal if I have thousands of users.
How can I list all files under my organisation, including those that are not shared?
The way domain wide delegation works is that it allows the service account to impersonate or act like a single user. The service account doesn't just get out write access to everyone's data.
This is due to a limitation on how the APIS work. Each request to an api must include a authorization header which contains an access token granting access to a single users data. If you want to access John's data then you need an access token for John, this will not give you access to John and Janes data.
So for the service account to work you need to be able to delegate to John then send another request deligateing to Jane to access her data.
THis may not be optimal for your application but its how it works. You will need to delegate to each user one at a time.