I'm trying to programmatically perform the following actions from within a Google Cloud Function:
Here’s what I’ve tried so far:
In both cases, the ownership transfer request fails with this error:
I/O error: 403 Forbidden
POST https://www.googleapis.com/drive/v3/files/156cD3L0-Yg_33qENsZseA6FiBHkwL9PpqYuzp7Q7whQ/permissions?sendNotificationEmail=true&transferOwnership=true
{
"code" : 403,
"errors" : [
{
"domain" : "global",
"message" : "Consent is required to transfer ownership of a file to another user.",
"reason" : "consentRequiredForOwnershipTransfer"
}
],
"message" : "Consent is required to transfer ownership of a file to another user."
}
Has anyone successfully transferred file ownership via the Google Drive API from within a Google Cloud Function, especially when dealing with personal Google accounts?
I would appreciate any help on:
Thanks in advance!
Solved! Go to Solution.
Hi @aejaz,
Welcome to Google Cloud Community!
Based on the Google Drive API documentation, you can only transfer file ownership through the API if both users are in the same Google Workspace domain. It’s a security measure to keep data from being accidentally or improperly shared across unrelated accounts. However, it is mentioned in this section that you can transfer manually by updating the file permission.
Since you're working with personal Gmail accounts, the API just doesn't support ownership transfers through code—even if you're using OAuth 2.0 or a Service Account.
You may want to try this post I saw on github using App Script to transfer file ownership. Since this site is not managed by Google, it might be outdated or incorrect.
You may also want to keep track of this feature request related to your concern.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.
Hi @aejaz,
Welcome to Google Cloud Community!
Based on the Google Drive API documentation, you can only transfer file ownership through the API if both users are in the same Google Workspace domain. It’s a security measure to keep data from being accidentally or improperly shared across unrelated accounts. However, it is mentioned in this section that you can transfer manually by updating the file permission.
Since you're working with personal Gmail accounts, the API just doesn't support ownership transfers through code—even if you're using OAuth 2.0 or a Service Account.
You may want to try this post I saw on github using App Script to transfer file ownership. Since this site is not managed by Google, it might be outdated or incorrect.
You may also want to keep track of this feature request related to your concern.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.