How to remove access to a shared Google Docs collection?

I’m trying to figure out how to stop sharing a Google Docs collection with others. I’ve been messing around with the API but I’m stuck.

Here’s what I tried:

CollectionFeed sharedStuff = service.getFeed(collectionUrl, CollectionFeed.class);
for (CollectionEntry item : sharedStuff.getEntries()) {
    item.revokeAccess();
}

But it’s not working. I’m not sure if I’m using the right URL to get the collection. Is this correct?

https://docs.google.com/api/collections/1234567890/permissions

Can anyone help me out? I just want to remove all sharing permissions from this collection. Thanks!

I’ve dealt with similar issues when managing shared Google Docs collections. From my experience, the approach you’re taking with the API isn’t quite right. Instead of trying to revoke access for each item individually, you should focus on modifying the permissions of the collection itself.

Try using the Drive API instead of the Docs API. You’ll want to use the ‘permissions.delete’ method on the collection’s ID. Something like this:

DELETE https://www.googleapis.com/drive/v3/files/{fileId}/permissions/{permissionId}

Replace {fileId} with your collection ID and {permissionId} with the specific permission you want to remove. You’ll need to iterate through all permissions to remove them completely.

Also, make sure you have the necessary authorization scopes. For managing permissions, you typically need ‘https://www.googleapis.com/auth/drive’ scope.

Hope this helps point you in the right direction. Let me know if you need more clarification on implementing this.

hey there, i’ve had this problem too. the trick is to use the drive API, not docs API. you wanna hit this endpoint:

https://www.googleapis.com/drive/v3/files/{collectionId}/permissions

then delete each permission. make sure u got the right scopes tho. good luck!

I’ve encountered this issue before when managing shared Google Docs collections. The API approach you’re using isn’t quite right for this task. Instead of working with individual items, you need to focus on the collection’s permissions as a whole.

For this, you should use the Google Drive API. The endpoint you want is:

https://www.googleapis.com/drive/v3/files/{collectionId}/permissions

You’ll need to list all permissions first, then delete them one by one. Make sure you’re using the correct authorization scope: ‘https://www.googleapis.com/auth/drive’. Also, be cautious when revoking permissions, as it might affect collaborators’ access unexpectedly.

If you’re still having trouble, double-check your collection ID and ensure you have the necessary permissions to modify sharing settings.