Is Google Drive API broken? I can't make it to send email notification

Viewed 261

today i have got a problem with receiving a notification email after creating a new file to Google Drive through the API and sharing it with another email. I was using "sendNotificationEmail" => true and it was working for 1+ year. Today it's not working and i couldn't find anything about that. I am using a service account for that. I tried to create a file manually and share it with the same email i used through the API and it worked ( I received an email notification on the chosen email address ). Here is a code sample.

$share_email = "foo@example.com";
$filename = "This is a title";
$content = "This is a content";

$credentialsFile = PATH_TO_JSON;
$client = new Google_Client();
$client->setApplicationName('gdocs');
$client->setAuthConfig($credentialsFile);
$client->setScopes([
    'https://www.googleapis.com/auth/drive',
    'https://www.googleapis.com/auth/userinfo.email'
]);
$gDrive = new Google_Service_Drive($client);

$file = new \Google_Service_Drive_DriveFile();
$file->setName($filename);
$file->setMimeType('text/plain');
$file = $gDrive->files->create($file, [
    'data' => $content,
    'mimeType' => 'text/plain'
]);

$permission = new Google_Service_Drive_Permission();
$permission->setType('user');
$permission->setRole('writer');
$permission->setEmailAddress($share_email);
$gDrive->permissions->create($file->getId(), $permission, array(
    'fields' => 'id',
    'sendNotificationEmail' => true
));

Result: foo@example.com gets the shared file, but doesn't receive any email.

Expected result: foo@example.com receives email as well as the shared file.

Is there anyone experiencing the same problem or anyone knowing a fix about that ?

P.S. I am using v3 of the API.

P.S.2 I tried with oAuth2 and it's working great ( the email i am sharing a file with is receiving a notification ).. However i would like to keep using it with a service account if possible.

0 Answers
Related