I'm building a php web app that needs to upload files to a Google Drive which belongs to a user (let's call him Bob). I used a Google Drive service account (let's call it [email protected]).
Bob created a folder ("uploads") in his Google Drive and shared it with [email protected].
The service account ([email protected]) can user the Drive API to list the files in that shared upload folder and upload files to it. The uploaded files show up in Bob's Google Drive as well. So far so good.
The owner of the files uploaded by [email protected] is [email protected], as one could expect. This has the following consequences:
How can this use case be handled (cleanly)? I see 2 possible solutions:
Google Apps Customers: You can't make someone outside of your domain the owner of your Google Doc. Only Google Apps customers in Premier, Government, and Education domains can transfer ownership of a synced or uploaded file (like a PDF or image file).
Consumer Drive users: You can't transfer ownership of a synced or uploaded file (like a PDF or an image file).
Please help!
Info regarding offline access and access tokens
I think that you should see this page: Perform Google Apps Domain-Wide Delegation of Authority. This page shows how to use SA to invoke requests in behalf of Bob
user. This page contains Java
code which describes how to create Drive
object for Bob
. Using this Drive
you will be able to upload file and the owner of the file will be Bob
not [email protected]. I am using this method a lot and it works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With