Google Drive SDK: To copy files from a user to another user via Domain Super Administrator access right - google-drive-api

Say, I am a Domain Super Administrator. And, there are User A (source - files to be copied from) and User B (destination - files to be copied to). Is there any Google Drive SDK API available for this feature?
When I read this: https://developers.google.com/drive/v2/reference/files/copy, this API allows only to copy into my own Google Drive.
Please help. Thanks.

Use domain-wide delegation to impersonate each user https://developers.google.com/drive/delegation.
Authenticate as source user and share file with target user https://developers.google.com/drive/v2/reference/permissions/insert
Authenticate as target user and copy source file to produce target copy of file owned by target user https://developers.google.com/drive/v2/reference/files/copy

Related

With Service account, Not getting any files / folder list with PHP

What will extra setting to get files / folder from google drive API with service account? Currently getting empty results.
Same code working with credential web scope with client id and secrets key but not with service account.
When you use a web client. It pops up and requests authorizaiton. In this way a user is granting your application access to their data. So a file.list will return the files on the users google drive account.
The same thing is happening with your service account. Only service accounts are pre authorized. Your file.list is returning no files becouse the service account doesnt have acess to any files yet. You see it has its own drive account.
Options.
Upload files to the service accounts drive account.
open your credetials.json file. Look for the service account email address. Take that address and share a directory or file on your personal drive account with the service account.
Now do a file.list. It should have files.

Can I make Google Drive available on my home network as a network drive?

Can I create a connection on one computer or device that exposes my drive to the rest of my network as a network shared drive?
My specific use case is that I have an older scanner that is connected to my wife that scans files and can send them to an email address, or to a network shared location. I’m trying to get it to send files directly to my Google drive though. Is there any way I can have computer connect to drive that lets the rest of the network see it as a shared drive?
Google Drive integration into Windows means that there will be some folder that acts as the Google Drive drop folder.
That folder, typically under your Documents folder can be Shared:
Right-click
Properties
Sharing tab
Click Advanced Sharing
Check Share this folder
Click Permissions
Grant Everyone the Change permission
Good question, totally fits StackOverflow, and definitely shouldn't be closed.

Transfer owner all documents to Administrator account using API (Google Drive)

I'm using Google Apps for Work. I try to take ownership for ALL file in user's Google Drive to Administrator account using APIs, via the latest Drive API http://support.google.com/a/bin/answer.py?hl=en&answer=1247799
With super admin permission, I can't use setownerto take ownership (action not allowed)
Only the owner of the file can grant access or ownership to other users. Even as admin, you won't have that kind of permission.
In order to accomplish this, as an admin you can "impersonate" the user and then perform actions on user's behalf.
This is done using service account with domain wide delegation permissions.
After doing this, you can call the API's as the user and give the admin(yourself) owner permissions of the user's files.
Hope this helps.

How multiple users in a Web Application can access the single Google Drive using Google API

I have a web application which will create users. And I have a single Google Drive. Once a user is create a folder will be assigned to that user in that Google Drive. That user can access only the folder allocated. Every time the user logs in from the web application the files within the allocated folder are able to view and the user can also upload and download files to that folder only. How this is achieved using Google API.
To start with you are going to need a create a service account for your application. The application will own the google drive account.
https://developers.google.com/accounts/docs/OAuth2#serviceaccount
Then your application is going to have to create the directory for the new user and associate the user with the directory's fileid (remember directorys are just files in google drive) the directory name could change so save the file id not the directory name to be sure.
Then it should simple be a matter of your appilcation uploading / viewing the files to the correct directory depending upon who is loged in. Since you will have the id for the directory it will be easy enough to list them the files already in that directory. as well as uploading directly to that directory.

How to transfer File Ownership for a Document which admin doesn't own?

Use Case
As admin service account, transfer Document Ownership using the Google Docs API, similar to the built in cPanel "Advanced Tools" -> "Document ownership transfer"
Constraints
APIs are being invoked in context of a Google Apps admin service account rather than the end-user account since APIs are being invoked from Google Apps Script in Sites page
Authorization is OAuth 1.0 since this is what Apps Script supports
What works:
Transferring ownership of the admin service account's own files to another user's account as documented here
What is required:
Transfer ownership of another user's files, ideally without them sharing any permissions with the admin service account; if there's no other way of doing it, they could share edit permissions on the file with the admin service account.
Currently this returns a
" ServiceException - You do not have permission to share these item(s):"
What you're trying to do is possible by impersonating the user using the admin account. The documentation shows how to do this here.
Essentially, start by requesting the API URL with default replaced with the current owner's email address. The request must be made while authorized as the admin user, though.
https://docs.google.com/feeds/user#yourdomain.com/private/full/
Once that URL is requested, all feed URLs will be returned with that email already present. Then, simply change ownership as you would normally.