You are creating an internal App Engine application that needs to access a user's Google Drive on the user's behalf. Your company does not want to rely on the current user's credentials. It also wants to follow Google- recommended practices.
What should you do?
Correct Answer: D
To access a user's Google Drive on their behalf without relying on the user's credentials and following Google- recommended practices, you should use a service account with domain-wide delegation.
* Create a Service Account:
* Go to the Cloud Console, navigate to IAM & Admin > Service Accounts.
* Click "Create Service Account" and provide necessary details.
* Grant Domain-Wide Delegation:
* Edit the service account to enable "G Suite Domain-wide Delegation".
* Download the JSON key file.
* Configure API Access in G Suite:
* Go to the Google Admin Console.
* Navigate to Security > API Controls > Domain-wide Delegation.
* Add a new API client and use the client ID from the service account.
* Authorize the necessary API scopes (e.g., https://www.googleapis.com/auth/drive).
* Implement in Application:
* Use the Google API Client Library for the desired language.
* Load the service account credentials and perform user impersonation to access Google Drive.
References:
* Domain-wide Delegation of Authority
* Using OAuth 2.0 for Server to Server Applications