There are plenty of resources involving sharing files in Google Drive but I can't find anything useful to Python and the references by Google aren't Python-specific.
I've saved an item ID into the variable selected_id. In this case, I want to make that file shareable by URL to anyone for reading.
service.permissions().create(body={"role":"reader", "type":"anyone"}, fileId=selected_id)
This is what I have so far but I don't think I formatted it correctly at all.
Like the title states, how would I share a file by ID on GDrive using Python? Thanks in advance.
Looks like you've got the correct format as per Permissions:Create
Perhaps you just need to add .execute()
on the end?
service.permissions().create(body={"role":"reader", "type":"anyone"}, fileId=selected_id).execute()
Also is you're looking for examples using the Python API check out the following repository: https://github.com/gsuitedevs/python-samples
I would image that you're code might look like something similar to this: https://github.com/gsuitedevs/python-samples/blob/master/drive/driveapp/main.py#L57
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.