0

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.

NewAtThis
  • 33
  • 4
  • 1
    Define `doesn't seem to be working` - do you get an error? Or a response at all? – Rafa Guillermo Aug 21 '20 at 12:28
  • @RafaGuillermo I'm not actually sure about how to check the response, every-time I try var dumping the creation of the permissions I only get a GuzzleHttp Request object. As for the script, it doesn't seem to be throwing any types of exceptions. How would I go about checking out the response sent by Google in PHP? – NewAtThis Aug 21 '20 at 19:12
  • 1
    Assign the request to a variable and log it - something like `$result = $service->permissions->create($status['id'], $permissions);` – Rafa Guillermo Aug 24 '20 at 10:22
  • @RafaGuillermo Thanks for your help, I managed to figure out I was putting the various parameters in the wrong spot. I've fixed it now and it works! – NewAtThis Aug 25 '20 at 16:50

1 Answers1

0

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);
NewAtThis
  • 33
  • 4