hemanthcm's avatar

hemanthcm started a new conversation+100 XP

4mos ago

I am using the Google PHP API Client ("google/apiclient": "^2.15") within a Laravel service account to automate Google Sheet creation. To avoid hitting the Service Account's storage quota, I must immediately transfer ownership of the created sheet to a specific target user ($email).

Current Status: The code successfully initiates the transfer, but the final API call consistently fails with a 403 Consent is required error, forcing the recipient to manually click an acceptance email.

PHP Version - 8.2.1 Laravel - ^10.10 Client Library - "google/apiclient": "^2.15"

$newOwnerPermission = new \Google_Service_Drive_Permission();

$newOwnerPermission->setRole('owner'); 

$updateOptions = [
    'transferOwnership' => true, 
    // We CANNOT use 'sendNotificationEmails' => false here, as the client rejects it with:
    // "unknown parameter: 'sendNotificationEmails'"
];

$driveService->permissions->update(
    $spreadsheetId,
    $targetPermissionId,
    $newOwnerPermission,
    $updateOptions
);

the below error response i am getting

 local.ERROR: Google Drive API Error during ownership transfer: {
  "error": {
    "code": 403,
    "message": "Consent is required to transfer ownership of a file to another user.",
    "errors": [
      {
        "message": "Consent is required to transfer ownership of a file to another user.",
        "domain": "global",
        "reason": "consentRequiredForOwnershipTransfer"
      }
    ]
  }
}

Given that I am constrained by the current PHP Client Library version (^2.15), has anyone found a reliable workaround to suppress the consent requirement in the Drive API v3 using alternative parameters or a different sequence of operations that is accepted by this specific client version?

Possible workarounds I'm interested in:

A known, functional alias for the sendNotificationEmails parameter in this version.

A confirmed sequence (e.g., temporary public share, then transfer) that guarantees consent bypass using only standard permissions:insert/update parameters (role, transferOwnership, emailMessage).