Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a Google Drive file without sending notification email

I am using Google Drive Java API. I need to copy a file from one Google domain to another, so my approach is the following:

  1. authenticate with source domain service account
  2. share file with user in destination domain
  3. authenticate with destination domain service account and impersonate the user
  4. copy the original file from origin domain to destination domain
  5. delete the share permission from the original file

Everything works as expected except that I don't want the destination owner to receive the Google Drive email notifying him about the shared file. When the file is shared via the Web GUI one can disable the notification email so I guess this is also possible via the API, the question is how ^^ Anyone?

PS: I am open to new 'less tedious' methods to create a copy of a file from one domain to another if that is possible.

like image 732
momo Avatar asked Feb 27 '14 14:02

momo


People also ask

When you share a Google Doc with someone do they get an email notification?

Turn on notifications in Google Drive so you know when people share files with you or mention you in a comment. Notifications appear in Chrome Browser. On Android devices, notifications also appear in your Google Docs, Sheets, and Slides apps.

Does sharing on Google Drive send an email?

Email collaborators right from a Google Docs, Sheets, or Slides file. If you're working on a shared drive file, you can email all members of the shared drive at once.

How do I share a link in Google Drive without email?

Share the File or Folder Through Link Non-Gmail users can access Google Drive files and folders via a link sent to them. Right-click the file or folder and click Share > Get link. Then, click Restricted and select Anyone with the link. Before sending the email, make sure you use the right permission settings.


2 Answers

On step 2, when sharing the file with the new user, you'll be using the permissions.insert() API call. You'll want to specify the sendNotificationEmails=false parameter along with this call to suppress the email notification.

like image 74
Jay Lee Avatar answered Oct 06 '22 18:10

Jay Lee


In the Google Drive API V3 with permissions.create() it has changed to singular: sendNotificationEmail=false

In a POST request it would be like this:

https://www.googleapis.com/drive/v3/files/*FILEID*/permissions?sendNotificationEmail=false
like image 35
Ramon Carceles Avatar answered Oct 06 '22 18:10

Ramon Carceles