Google Apps Domains: drive migrator - google-docs

Is it possible to build a cross-domain Drive migrator?
The DocsList API was great but it doesn't support files. Google Drive SDK now works with files but doesn't return Permission emails for privacy:
Here: we can read:
value string The email address or domain name for the entity. This is
not populated in responses. You can use the alias me as the value for
this property to refer to the current authorized user.
We have many customers (Google Apps For Business) that have to migrate their own accounts (email and drive files) or change the primary domain of Apps and it's not so easy expecially for an enterprise environment.
I'll use drive SDK as well, but I have to "map" correctly shared files and I need emails of Permissions (like ACLFeed before)

Get your ACL feeds with the DocumentList API, then migrate with Drive API.
The ids are the same, except for the root folder. But the root folder can be accessed with the alias root in both API

Related

document creation using google APIs in python

Is is possible to give google service-account's access to whole drive instead of just folders?
I'm unable to switch to a new directory using google docs API in python. It was possible to jump into a folder and then create the document there using google drive APIs but I want to use docs API only and I can't see any way to jump into another folder.
Is is possible to give google service-account's access to whole drive instead of just folders?
If you have a Workspace domain, I'd suggest granting domain-wide authority to the service account in order to impersonate the regular user's My Drive and access everything they can access. See Delegating domain-wide authority to the service account for more details about how to accomplish this.
If this is not an option for you, you should share all top-level items on the Drive, since there's no direct method to share the full My Drive.
It was possible to jump into a folder and then create the document there using google drive APIs but I want to use docs API only and I can't see any way to jump into another folder.
You need to use Drive API to move files between folders. Docs API cannot be used for that.
Sidenote:
Not sure if you're aware of this, but please notice that, if you create a document via Docs API, you can only create a blank document, since all fields apart from title are ignored in this method (see documents.create). If you want to add text, change other properties, etc., you'll have to use documents.batchUpdate.
I'm mentioning this since I don't know whether that was the reason you wanted to create the document via Docs API.

taking ownership of all files and folder created inside my folder in google drive using APIs

my scenario: I have created a folder inside my Google Drive with the name called folder-root and shared that folder with my colleagues. My company is using G-Suite for business. Now my other team members have started uploading files and folder inside my folder.
Now I want to take ownership of all files and folder created/uploaded inside my folder to me.
e.g. the hierarchy is
folder-root --I am the owner
folder-1 -- Bob is the owner
file-1 -- Bob is the owner
folder-2 -- Alice is the owner
file-2 -- Alice is the owner
file-3 -- marry is the owner
Since all the files and folders are created inside my Drive folder so I want to take ownership of all files/folders created inside my folder.
How can do that , I have tried using Google API's v3, and I am getting an error: Bad Request. User message: "Sorry, you do not have permission to share."
this message is coming when I use file id of bob, Alice or marry with my email address
Code is in node.js
function transferOwnerShip(auth) {
const drive = google.drive({version: 'v3', auth});
drive.permissions.create({
fileId: '1_o-rhbFinu1_LZYniFNo1gV0Epv5mYU5',
transferOwnership: 'true',
resource: {
role: 'owner',
type: 'user',
emailAddress: 'my-name#company.com'
}
});
}
To transfer the ownership of file (including Google Drive folders which in the REST Google Drive API are referred as files) the code should be executed with the permissions of the file owner. This could be done using OAuth instead of using Node.js (or other platform / programming language use Google Apps Script which handles the OAuth for your with some restrictions.
If you can't get that the file owners do the ownership transfer you will need a Google Service Account with domain-wide delegation of authority to impersonate them. This requires that a G Suite admin gives this privilege to the service account.
Another option is that the G Suite admin transfer the ownership of all the files of those user to another user. If you aren't that user, they should transfer the ownership of the files to you.
You could validate the above directly with G Suite Support if you are a G Suite admin.
Another option is to copy the files that you don't own, then remove the files owned by others from your folders. In order to prevent that this happens again, change from edit to view on the sharing settings of your folders. This could be done manually or by using the Google Drive API.
Resources
Transfer Drive files to a new owner (broad article for G Suite admins)
Transfer ownership of a file (no programming)
Related
Transfer ownership of a file to another user in Google Apps Script
How can I force all files in a folder to be owned by the folder owner in Google Drive?
Take ownership of other users Drive-files using Google Apps Script
Google Drive: How do I transfer ownership using the Python SDK?

Can I set my Node.js Backend to access my Google Drive to list/download/upload?

I want my back-end to use the Google Drive API to be able to list/upload/download files from a normal google drive folder (as opposed to a cloud bucket). But not the user's Google Drive, only MY drive.
As far as the end-user is concerned they would just be on my site but when they upload a file, my back-end would receive it and store it on MY google drive. Same for a simple list of files in the folder, I just want them to click my front-end button and have it send a call to my back end, then my back-end sends a call to the google API and returns a list.... effectively making my back-end the middle man for my google Drive. So that my users don't need a google account to access my site
My reasoning is I want my users to NOT need a google account, but I will still need to share these folders with contractors. The contractors can have a google account, that doesn't bother me, And I don't want to have to re-invent the wheel by building a separate front-end for my contractors to download these folders when Google Drive already has perfectly working UI that will zip a folder and download it already built.
So I want:
User -> front-end -> my backend -> google drive
I have seen posts on doing this for other services, like analytics and calendar, but I really need drive capabilities.
A user could be either my client who needs to upload and download OR my client's clients (who will only ever need to upload)
Main Question:
Can I set my NodeJS Back-end to access my Google Drive to list/download/upload
If it is possible:
How, and should I? As I write this, I am thinking of issues... like, will uploading a file from Front-end to back-end then to google drive be too cumbersome to be practical? (These are video files that could be around 300-400mb).
If not possible OR it is too cumbersome:
Can anyone suggest anything that will make access to Google Cloud bucket folders easier? Package? Example? Method? Tutorial?
Frontend: VueJS with axios
Backend: super basic node/express API/back-end on an AWS ec2 server
The short Answer is Yes.
The way to do this is with a service account as these accounts are special credentials to be used by a service. These accounts are of the form: service-account-name#project-id.iam.gserviceaccount.com.
Once you have the service account you will need to grant access to this service account on the Google Drive location. To grant access to this service account share the location (files or folders) with this account, as if you were sharing the files with another user, just by adding the email on the edit permitions.
And Finally to manipulate the files there programatically you can use the NodeJS Client Library which will make the task easier than manipulate the API calls directly.

using iframe googledocviewer - index google this?

I used the googledocviewer to view some word an excel sheets on my site:
<iframe src="https://docs.google.com/viewer?url=http://domain.de/media/dokumente/worddocument.doc&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>
The documents are on MY server.
It works fine, but now my question:
Generally, on the live site, all IP´s are on my server blacklisted, because only 5 specially IP´s have access to the site.
So, the iframe try to load the googledocviewer, but google is blacklistet (on my server, because it´s not an ip from the 5)
So, the screen shows:
no document available.
If I set the googledocviewer IP to my whitelist - indexing Google all my documents and save they at any google-server?
The documents are private !!! No other IP´s and users is allowed, to see this docs.
My suspicion:
Because I use the googledocs viewer and set the googledocsviewer IP to a whitelist, other users can now access to these private documents....
Sorry for my bad english...I'll work on it.
Best regards,
Thorsten
As mentioned in Whitelist domains for Google Apps, you can still set which files can be shared and you also can choose more permissive settings to be sure that you don't share confidential files.
You can allow file sharing in Google Drive for organizations that you trust by whitelisting their domain. After you whitelist a domain, you then grant Drive access so that users in your organization can share files and folders with users in the trusted domain.
Furthermore, it was also mentioned in grant sharing access for whitelisted domains
For Google Apps Unlimited, Google Apps for Education, and Google Apps for Nonprofits, you grant file sharing access by changing Drive sharing settings. For details, see Set file sharing permissions.
For Google Apps for Education, you grant access to classes by changing Classroom settings. For details, see Whitelist domains for Classroom.

Share files with between group of user using Microsoft Live sdk

I am developing an application that requires to share files between users using Microsoft Live sdk. But only resource that I came across is by providing a shared link or embed link which expires after some time and are open to public usage. Instead, I want to share files among only certain group of one drive users and that too, permanently. This functionality is already present in one drive itself. Is there any way of doing it using one drive api ?
UPDATE: google drive api supports these.
The OneDrive API support the creation of sharing links, which would be easy to send to the group that you want to give access to a specific file or folder. These links do not expire, however they can be revoked.
Here is an example of the kind of request you can use to create one of these links
POST https://api.onedrive.com/v1.0/drive/items/{item-id}/action.createLink
Content-Type: application/json
{
"type": "view"
}

Resources