This is a sample script for transferring the ownership of a file to another user using Google Apps Script.
In the current stage, about the consumer account (gmail.com) the specification for transferring the ownership of a file has been changed as follows. Ref
- The current owner initiates an ownership transfer by creating or updating the prospective new owner's file permission. The permission must include these settings: role=writer, type=user, and pendingOwner=true. If the new owner is creating a permission for the prospective owner, an email notification is sent to the prospective new owner indicating that they're being asked to assume ownership of the file.