Google drive api 从Windows Google Drive应用程序传输文件的Google Drive所有权失败

Google drive api 从Windows Google Drive应用程序传输文件的Google Drive所有权失败,google-drive-api,Google Drive Api,同样的问题-似乎没有解决方案。我添加了自己的问题a)针对不同的语言,b)更简单的代码,并尝试了两种方法。我试过其中一个答案,但认为另一个不适用 我需要将Google驱动器文件或文件夹的所有权从我转移给其他人。如果文件是在Google Drive(web)中创建的,那么它可以正常工作。如果该文件是由API创建的(例如通过Google Drive Windows应用程序),则该文件将失败,因为该文件[403]的权限不足。 我没有在工作中使用谷歌应用程序,因此无法模拟或使用管理工具 我试过:

同样的问题-似乎没有解决方案。我添加了自己的问题a)针对不同的语言,b)更简单的代码,并尝试了两种方法。我试过其中一个答案,但认为另一个不适用

我需要将Google驱动器文件或文件夹的所有权从我转移给其他人。如果文件是在Google Drive(web)中创建的,那么它可以正常工作。如果该文件是由API创建的(例如通过Google Drive Windows应用程序),则该文件将失败,因为该文件[403]的权限不足。

我没有在工作中使用谷歌应用程序,因此无法模拟或使用管理工具

我试过:

    public bool ChangeItemOwnership(DriveService service, string fileId, string myPermissionId, string toPermissionId)
    {
        try
        {
            Permission permission = service.Permissions.Get(fileId, myPermissionId).Execute();
            if (permission.Role == "owner")
            {
                permission = service.Permissions.Get(fileId, toPermissionId).Execute();
                permission.Role = "owner";
                PermissionsResource.UpdateRequest updatePermission = service.Permissions.Update(permission, fileId, toPermissionId);
                updatePermission.TransferOwnership = true;
                permission = updatePermission.Execute();
            }
        }
        catch
        {
            return false;
        }
        return true;
    }

仅供参考,我授权:

    static string[] Scopes = { DriveService.Scope.Drive };

            credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.Load(_resourceStream).Secrets,
                Scopes,
                "user",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;
我想知道问题是否出在上面的“用户”身上,但我还没有看到其他答案——我试着把我的电子邮件地址放进去,但结果是一样的。还考虑了不同的范围,但看不到任何可能适用的范围

它甚至在谷歌的API页面上失败:

我真的很坚持。有人能帮忙吗


编辑:根据请求,在文件上显示与我(我的用户)相关的权限。我已经隐藏了一些可能更好隐藏的东西(不确定)。唯一的区别是ETag和SelfLink

我通过以下方式获得许可证ID:

About about = service.About.Get().Execute();
fromPermissionId = about.PermissionId;
以下是该行后面的权限:

Permission permission = service.Permissions.Get(fileId, fromPermissionId).Execute();
无法移交所有权的文件:

permission
{Google.Apis.Drive.v2.Data.Permission}
AdditionalRoles: null
AuthKey: null
Domain: "gmail.com"
EmailAddress: "***********@gmail.com"
ETag: "\"fbeGFVkC******djp1CYyuwDABw/aPlNOCkOt******X9klsSp45w\""
Id: "1726185******1763882"
Kind: "drive#permission"
Name: "James Carlyle-Clarke"
PhotoLink: null
Role: "owner"
SelfLink: "https://www.googleapis.com/drive/v2/files/0B******DI_IeTk9z******ZTRkk/permissions/1726185******1763882"
Type: "user"
Value: null
WithLink: null
permission
{Google.Apis.Drive.v2.Data.Permission}
AdditionalRoles: null
AuthKey: null
Domain: "gmail.com"
EmailAddress: "***********@gmail.com"
ETag: "\"fbeGFVkC******djp1CYyuwDABw/cT4fcr2Tka******EpimOAHa4hw\""
Id: "1726185******1763882"
Kind: "drive#permission"
Name: "James Carlyle-Clarke"
PhotoLink: null
Role: "owner"
SelfLink: "https://www.googleapis.com/drive/v2/files/1Uyg0o******hZKvIRS-ghAi0GeJ******7029Eofr1o/permissions/1726185******1763882"
Type: "user"
Value: null
WithLink: null
可移交所有权的文件:

permission
{Google.Apis.Drive.v2.Data.Permission}
AdditionalRoles: null
AuthKey: null
Domain: "gmail.com"
EmailAddress: "***********@gmail.com"
ETag: "\"fbeGFVkC******djp1CYyuwDABw/aPlNOCkOt******X9klsSp45w\""
Id: "1726185******1763882"
Kind: "drive#permission"
Name: "James Carlyle-Clarke"
PhotoLink: null
Role: "owner"
SelfLink: "https://www.googleapis.com/drive/v2/files/0B******DI_IeTk9z******ZTRkk/permissions/1726185******1763882"
Type: "user"
Value: null
WithLink: null
permission
{Google.Apis.Drive.v2.Data.Permission}
AdditionalRoles: null
AuthKey: null
Domain: "gmail.com"
EmailAddress: "***********@gmail.com"
ETag: "\"fbeGFVkC******djp1CYyuwDABw/cT4fcr2Tka******EpimOAHa4hw\""
Id: "1726185******1763882"
Kind: "drive#permission"
Name: "James Carlyle-Clarke"
PhotoLink: null
Role: "owner"
SelfLink: "https://www.googleapis.com/drive/v2/files/1Uyg0o******hZKvIRS-ghAi0GeJ******7029Eofr1o/permissions/1726185******1763882"
Type: "user"
Value: null
WithLink: null

第二次更新: 找到建议使用Insert()的帖子-

试过了。它失败,错误
请求错误。用户消息:“您还不能更改此项目的所有者。(我们正在处理)。”[400]
有趣的是,上面的旧方法仍然给出相同的403错误。 仍在寻找解决方案,但我希望谷歌有人一直在潜行,现在正在努力修复它


第三次更新: 已尝试
PropertyList properties=service.properties.List(fileId.Execute()

这两个文件(我可以更改所有权的文件和我不能更改所有权的文件)上都没有属性



如果您需要更多信息,请告诉我。

向我们展示两种情况下的文件所有者。一个案例(api)可能使用服务帐户?@ZigMandel,你认为这就是你想要的吗?如果不是,请告诉我。因此,在这两种情况下,它都是同一个文件所有者。奇怪,哦,是的。这快把我逼疯了。我同意一定有某种隐藏的价值或附加的标签或任何东西。我甚至想知道Google Drive(Windows)是否因为管理文件而“锁定”了该文件。但那太疯狂了!此外,我给出的另一个链接说,它是任何谷歌API创建的文件……如果有人能尝试复制它,我会很感兴趣——使用上面给出的代码应该很容易做到,然后用GD的web版本创建的文件与windows版本创建的文件进行测试。如果需要,我可以提供更多的代码(如创建DriveService等)。