0

We are developing an application, in that we need to get all the files of all users in the domain. We have enabled service account with domain-wide delegation already, but whenever we tried to access all user's drive, it is required to get each user access token separately after setting each user id using google credential object method (e.g. googleCredentialBuilder.setServiceAccountUser({email_id})). We are using Drive API client library for Java and admin SDK for getting all the users in the domain.

So, our concern is to get all users to drive files using a super admin access token. Is there any alternate way to get all users to drive files using domain/admin-level access token. Kindly help me in this regard.

Lin Du
  • 88,126
  • 95
  • 281
  • 483
  • What have you tried so far ? Please read this article https://stackoverflow.com/help/minimal-reproducible-example and edit your question by adding code illustration your issue – Fourat Nov 14 '19 at 12:44

1 Answers1

1

To obtain all the Drive files in the domain, you have to use delegation as follows:

  1. Use the Directory API users.list() API call to determine all users in the Google Apps domain.
  2. For each user obtained in step 1, do:

    2.1. Call files.list with the parameter q set to "me" in owners to get a list of all files the user owns.

To do all of this you don't necessarily need a superadmin account. You just need to set up credentials with domain-wide delegation enabled. You can read more about how to do it here.

carlesgg97
  • 4,184
  • 1
  • 8
  • 24