Google drive api 谷歌硬盘转让所有权

Google drive api 谷歌硬盘转让所有权,google-drive-api,Google Drive Api,我正在使用google drive php api更改文件的权限。当我将“角色”设置为“编写者”时,它会起作用,但当我将“角色”设置为“所有者”时,它会起作用,如下所示: $batch = $driveService->createBatch(); $userPermission = new Google_Service_Drive_Permission(array( 'type' => 'user', 'role' =

我正在使用google drive php api更改文件的权限。当我将“角色”设置为“编写者”时,它会起作用,但当我将“角色”设置为“所有者”时,它会起作用,如下所示:

$batch = $driveService->createBatch();
        $userPermission = new Google_Service_Drive_Permission(array(
            'type' => 'user',
            'role' => 'owner',
            'transferOwnership' => 'true',
            'emailAddress' => 'c*****@c*******.org'
        ));
        $request = $driveService->permissions->create(
            $fileId, $userPermission, array('fields' => 'id'));
        $batch->add($request, 'user2');
$results = $batch->execute();
我得到一个错误,必须将“transferOwnership”设置为true。但是,看来我已经把所有权设定为真了!我做错了什么

exception 'Google_Service_Exception' with message '{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "The transferOwnership parameter must be enabled when the permission role is 'owner'.",
    "locationType": "parameter",
    "location": "transferOwnership"
   }
  ],
  "code": 403,
  "message": "The transferOwnership parameter must be enabled when the permission role is 'owner'."
 }

transferOwnership
应设置为查询参数,而不是在请求正文中

例如:

$batch = $driveService->createBatch();
$userPermission = new Google_Service_Drive_Permission(array(
    'type' => 'user',
    'role' => 'owner',
    'emailAddress' => 'c*****@c*******.org'
));
$request = $driveService->permissions->create(
    $fileId, 
    $userPermission, 
    array('fields' => 'id', 'transferOwnership' => 'true'));
$batch->add($request, 'user2');
$results = $batch->execute();