C#从Google共享驱动器API v.3中删除文件

C#从Google共享驱动器API v.3中删除文件,c#,.net,permissions,drive,C#,.net,Permissions,Drive,我能够使用服务帐户成功地将文件上载到Google Drive共享驱动器(而不是不同的“我的驱动器”文件夹)。但是当我试图删除该文件时,我得到一个用户没有足够的权限来删除该文件。[403] 注意,在我的代码中,我有request.SupportsAllDrives=true设置为允许it访问共享驱动器的标志 我已经检查了服务帐户的权限ID和文件的权限ID,毫不奇怪,它们是相同的,因为服务帐户是将文件放在那里的人 你知道哪里出了问题吗 /// <summary> /// Perman

我能够使用服务帐户成功地将文件上载到Google Drive共享驱动器(而不是不同的“我的驱动器”文件夹)。但是当我试图删除该文件时,我得到一个
用户没有足够的权限来删除该文件。[403]

注意,在我的代码中,我有
request.SupportsAllDrives=true设置为允许it访问共享驱动器的标志

我已经检查了服务帐户的权限ID和文件的权限ID,毫不奇怪,它们是相同的,因为服务帐户是将文件放在那里的人

你知道哪里出了问题吗

/// <summary>  
/// Permanently delete a file, skipping the trash.  
/// </summary>  
/// <param name="service">Drive API service instance.</param>  
/// <param name="fileId">ID of the file to delete.</param> 
public async Task<string> DeleteDriveFile(DriveService service, string fileId)
{
    // get the user's permission id from Drive
    var getRequest = service.About.Get();
    getRequest.Fields = "*";
    var getResponse = await getRequest.ExecuteAsync().ConfigureAwait(true);

    string userPermissionId = getResponse.User.PermissionId;
    Debug.Print($"UserPermissionID: {userPermissionId}");

    var responseFile = service.Permissions.Get(fileId, userPermissionId);
    Debug.Print($"FilePermissionID: {responseFile.PermissionId}");

    string response = "";
    try
    {
        var request = service.Files.Delete(fileId);
        request.SupportsAllDrives = true;
        response = await request.ExecuteAsync().ConfigureAwait(false);
    }
    catch (Exception e)
    {
        Debug.WriteLine("Delete File Error: " + e.Message);
    }

    return response;
}
UserPermissionID: 0243088xxxxxx3009857
FilePermissionID: 0243088xxxxxx3009857
The thread 0x1398 has exited with code 0 (0x0).
Exception thrown: 'Google.GoogleApiException' in System.Private.CoreLib.dll
Delete File Error: Google.Apis.Requests.RequestError
The user does not have sufficient permissions for this file. [403]
Errors [
    Message[The user does not have sufficient permissions for this file.] Location[ - ] Reason[insufficientFilePermissions] Domain[global]
]