Google Drive Migration sharing issues - google-drive-api

We want to migrate all google drive docs from one domain to other domain. While i got some links on how to transfer ownership of files but the sharing of new transferred files is being nullified . Is there any way to preserve sharing properties also while we transfer?

I think it's currently NOT possible.
As noted in Set file sharing permissions, files inherit sharing policy if transferred within same organization of the file owner. As mentioned:
Files always inherit sharing policy from the organizational unit of the file owner. A file may therefore inherit a new sharing policy if the owner moves to a new organizational unit or if file ownership is transferred to someone in a different organizational unit.
With this, new file owner might need to share files and folders.
Hope that helps!

Related

How to find out whether a GDrive (not Shared) file has inherited permissions, specifically shared to domain?

I'm looking to switch all domain-shared files from "Shared with Domain" to "Shared with group". I'm trying to identify whether a permission on a GDrive file (not from Shared Drive) is inherited or not. However Drive V3 API does not appear to expose permissions/permissionDetails attribute in same way as Shared Drives. Is there an efficient way to get the "inherited" status of a permissions? Trying to avoid having to walk the folder hierarchy.
Background on use case: We have decided that shared to domain is overly broad as the company grows. We have many consultants and contractors who should not see everything in the firm. We want to switch from Shared to domain to Shared with groups to better manage least privilege. We are aware that we cannot change UI at this time.
Answer:
There's no direct way to get the inherited status of file permissions in Drive API.
Explanation:
permissionDetails is only available to shared drive items, and neither Permissions nor Files include any additional fields regarding inheritance.
Therefore, I don't think you can use inheritance to filter out the files to update.
Feature request:
There's a feature request in Issue Tracker related to this:
Sharing permission inheritance details not mention in API
You could consider starring it in order to keep track of it and to help prioritizing it, but since it hasn't had much activity, I'd strongly suggest you to file a new one using this template.
Related:
Permission details are not returned in Google Drive API V3
Google drive api v3 permission details

What criteria does google check to see which files require the new resourceKey?

Google recently announced that to access certain files on google drive my application should use a resouceKey along with the fileId when trying to access google drive through Api. When I checked the files in my google drive I find that not all files have the new resourceKey. I uploaded a new file and that too does not have the new resourceKey.
This lead me to wonder as to what criteria should a file satisfy to be requiring the new resourceKey?
Basically, the resourceKey is required for users who have not been shared the file specifically with them (that is, files shared with Anyone with the link or Anyone in the domain, but not shared with that user specifically) and which haven't accessed that file previously.
Because of this, files that you own, files that you have accessed before, and files that have been shared with you specifically don't require a resourceKey.
You can check the details of the impacted files on the alert center.
Reference:
Update to some Google Drive file links, admin decision recommended before July 23, 2021
Decide how to apply link-sharing security update to Drive
Access link-shared files using resource keys

Google Drive API permission to children files

We would like access to a client’s folder within their Google Drive and all files under that folder. This can either be a folder we create from the app or a folder the client picks.
The first approach I tried was to create the folder from the app.
The problem is that I am only able to list the folder itself, but NONE of the content. https://developers.google.com/drive/api/v3/folder
The second approach was to use the Google Picker API. There the
client can choose which folder(s) to give us access to. However we
can only get access to the folder, and none of the children
folders/files. https://developers.google.com/picker/docs
This seemed like an easy and straightforward use case. But can’t seem to find a solution in their documentation, or maybe I don’t comprehend some of the logic. A solution would be a way to either propagate the permission to all the files included in the folder it get’s picked or created… or to have the picker select all the children.

My preference is to continue with the Recommended scope https://www.googleapis.com/auth/drive.file . And it might be that the folder contains thousands of individual files multiple levels in, so it’s not a solution to manually pick the files. Any thoughts on this would be greatly appreciated, thank you!
A possible solution for your situation...
Is to create the folder in a shared drive.
Therefore, even though new files are added/updated/removed you will still be able to see all the updates and retrieve the information needed as you will have constant access to this folder.
Another solution which is more cumbersome...
Is to ask for user's permission and to re-authorize the application each time they are using it so in the case a new file is added you will have access to it.
Reference
Drive API v3 shared drives;
Drive API v3 manage shared drives.
The first approach I tried was to create the folder from the app. The problem is that I am only able to list the folder itself, but NONE of the content. https://developers.google.com/drive/api/v3/folder
The issue is probably the scope you authorized the user with. If you authorized with read only access your not going to be able to create you need full drive access to do that.
If you are using https://www.googleapis.com/auth/drive.file then you should create a folder with that and then create a file in the folder that i believe should work.
The second approach was to use the Google Picker API. There the client can choose which folder(s) to give us access to. However we can only get access to the folder, and none of the children folders/files. https://developers.google.com/picker/docs
There is no way to request access for a single folder or files. Its all or nothing really unless you use the https://www.googleapis.com/auth/drive.file scope which would only give you access to the files that your application created.

How to maintain Google Drive tree structure while having advanced ACL permissions?

My question concerns Google Drive.
I would like to know how to maintain the same tree structure for all my users accross the organization when I share it. While keeping advanced and customizable ACL permissions for folders and sub-folders.
I am the admin of my Google Business Apps and my Drive folder tree is very well organized and structured. I want some users of my organization to be added to a folder "A" so they can access a sub-folder "A.1", but not the other sub-folders "A.2" and "A.3".
Right now it is pretty messy and hectic if I want to save my tree structure. Indeed, if I want to save my tree structures in my users' Drive, I have to give them access to the main folder "A" so they will be able to access sub-folder "A.1". However, if I do it, my users will be automatically able to access the other sub-folders 1.2. and 1.3. (because the person has access to the main folder "A"). Therefore, I have to manually restrict the access to the sub-folder "A.1" only. That's a pain.
When I give to my users access to the folder "A.1" only, the folder is shared individually and my users' Drive tree structure is no more organized. After sharing 20 folders, my users' Drive becomes pretty messy, while mine remains completely clean (since I created the tree structure and I have all the permissions).
Does anyone know how to efficiently share an identically Drive tree structure among the whole organization, without compromizing on the ACL?
Thanks,
B.
PS: The only post related to this problem is here but it doesn't answer my question: Google Drive - Change owner on folder, sub-folders and content, while saving tree structure
Regrettably, Google Team drive does not currently allow assigning permissions to team drive sub-folders or sharing symlinks across team folders. :(
As a result, our organization ended up creating dozens of team folders each based on role access. This approach solved several problems but created others and makes it hard to share content between roles.
Ideally... GOOGLE should update Team drive to allow permissions to be managed at the drive as well as subfolder level. Until they do the only way to share content within a team drive across roles is one file at a time.

Moving a file into a Google Drive folder without changing its ACL

In Google Drive, when puting a file into a folder, the ACLs of the folder are added to the ACLs of the file.
Is there a way to avoid that? In my use case, a lot of user have "Can View" access on the folder, but only a subset of those will ultimately allowed to view that file. Even if we quickly follow with an ACL update request, there will be a short amount of time during which the visibility of the file is too broad for my use case.
Note that a solution involving having a short period of time during which the access is more limited that what it will ultimately be would be acceptable. Also, I am ready to use either Drive API or Document List API.
This might help
I was so happy when I found it! Unfortunately, it still cannot override file settings, in the case of a document owned by someone else than the containing folder's creator.