I've been trying to set permissions of a file I upload through code to a shared drive through a service account so that the file is publicly visible, unfortunately everything I've tried thus far doesn't seem to be working. Uploading the file to the shared drive works correctly, but making it publicly accessible does not. I create my permission like this below. Note, the below call is deferred.
$permissions = new Google_Service_Drive_Permission([
'type' => 'domain',
'domain' => '[DOMAIN]',
'role' => 'reader',
'allowFileDiscovery' => false,
'supportsAllDrives' => true,
'transferOwnership' => true,
'fields' => '*'
]);
$service->permissions->create($status['id'], $permissions);
$status['id'] is returned after all the file chunks are uploaded, and I've printed it to make sure that it is the correct file id. The service account uploads the file, so it should have permission to update these permissions, but it doesn't seem to be working. If it matters, the service account is a contributor on the shared drive. Any guidance would be appreciated, and I can further update my post with more of my code if needed.
It turns out I was putting the parameters in the wrong spot. In order to get what I wanted I used this
$params = [
'supportsAllDrives' => true
];
$service->permissions->create($status['id'], new Google_Service_Drive_Permission([
'role' => 'reader',
'type' => 'domain',
'domain' => '[DOMAIN]',
'allowFileDiscovery' => false
]), $params);
$service->permissions->create($status['id'], $permissions);