Using Service User to upload files to Google Drive by email address

I am connecting to a service account using a service account credential.

I'm trying to scale this up to be used for multiple users within the same company. All users will have Google accounts managed by this company, and I will have a gsuite service account for the entire company. How can I upload a file to users personal Google Drive based on an email address using a gsuite service account?

Jon Skeet

You want to use ServiceAccountCredential, with a User property set to the appropriate user.

Assuming you're loading the credentials using GoogleCredential, this isn't too hard. For example:

GoogleCredential credential = Google.GetApplicationDefault()

If you wanted to use the same original credentials for many different users, you could keep the result of CreateScoped(...) around, and just call CreateWithUser to create a new user-specific credential for each operation.


See more on this question at Stackoverflow