I want to update my user permissions using google drive api with PHP. I am doing like this-
$Service = new Google_Service_Drive($Client);
$OptParams = array(
'fields' => '*'
);
$Reponse = $Service->files->get($FileId,$OptParams);
foreach ($Reponse->getPermissions() as $PermissionValue) {
$PermissionId = $PermissionValue->getId();
$PermissionValue->setRole('reader');
$result = $Service->permissions->update($FileId,$PermissionId,$PermissionValue);
}
return $result;
From the above code I can get my file id and permission id both but its throwing me error on update method. What am I doing while updating the user permissions for a file.
I am getting this error-
Fatal error: Uncaught Google\Service\Exception: { "error": { "errors": [ { "domain": "global", "reason": "fieldNotWritable", "message": "The resource body includes fields which are not directly writable." } ], "code": 403, "message": "The resource body includes fields which are not directly writable." } }
Can anybody tell me What am I doing wrong or what am I missing? What is the correct way of updating the permissions for user?