我try 遵循这些文档,但它们没有提供如何使用该功能的工作示例.
这是我的实现:
async function transferOwner( ){
const authClient = await authorize();
const realFileId = '***fileId***';
const newOwnerEmail = '@gmail.com';
try{
const drive = google.drive({version: 'v3', auth: authClient});
const res = await drive.permissions.update({
fileId: realFileId,
permissionId: '***permission id that i found somehow***',
transferOwnership: true,
sendNotificationEmail: true,
email: newOwnerEmail,
"resource": {
"role": "owner"
}
});
console.log(result);
console.log(`transfered ownership to ${newOwnerEmail}`);
return result;
} catch (err){
console.log(`could not transfer ownership to ${newOwnerEmail}`);
console.log(err);
throw err
}
}
当我执行此代码时,状态代码为200,但我没有看到我的驱动器中有任何所有者发生更改.
我做错了什么?
如果需要,这就是res.尽管我不得不删除一大块响应,因为stackoverover并不容易发布这么多内容.
{ 标题:{100}, 状态:200, 状态文本:"OK", 请求:{ 响应URL:' https:www.googleapis.com/drive/v3/files/101/permissions/102? transferOwnership=真实发送通知邮箱=真实邮箱=103 ' }` 所有权转让给104
将 * 添加到我试图隐藏任何信息的地方.
我try 了多种方法来使用我的代码更改所有者,但都不起作用.
每次我收到成功消息和200状态代码时,但驱动器中没有反映任何内容.