Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can an Admin access the Google Drive contents of all the users in a particular domain?

I am developing a tool to automate the transfer of ownership of Google Drive documents from one user to another using Admin SDK which is run by the admin. I used the Data transfer API for the ownership transfer. I wanted to validate the transfer by checking the size/number of the google drive documents before and after the transfer for which the admin account must be able to access the Google Drive contents of all the users in the domain. Is there a way to do that? Or is there a better way to validate the data transfer?

I tried using the Drive API service for validating purposes by setting the 'key' to the target user account. All my attempts with the Drive API so far retrieved the Admin's Drive contents.

like image 861
Sigma Avatar asked Jun 02 '16 22:06

Sigma


Video Answer


1 Answers

Files.list will retrieve all the user's files, in this case it will get all your own files. In order for that query to work would be only if that user is also owner one of your files.

HTTP request

GET https://www.googleapis.com/drive/v2/files

Even as an admin you cannot access users files directly.

To access other user's files, as an admin you need to impersonate the users and then perform actions in their behalf.

This is achieved by using a service account with domain wide delegation of authority.

Typically, an application uses a service account when the application uses Google APIs to work with its own data rather than a user's data. For example, an application that uses Google Cloud Datastore for data persistence would use a service account to authenticate its calls to the Google Cloud Datastore API.

Google Apps domain administrators can also grant service accounts domain-wide authority to access user data on behalf of users in the domain.

Here's a related SO ticket, discuss the most efficient process for transferring of users files: Most efficient process for transferring ownership of all of a user's files using the Google Drive API

like image 80
Android Enthusiast Avatar answered Oct 05 '22 01:10

Android Enthusiast