I'm working on an automation script which automates the Google Spread Sheets using python and gspread library. Using this I'm able to share the created spread sheet using share() method to a single user. But how to share it with more than one users ? Please suggest me the way to do that !
Code I used
spreadSheet.share("example@gmail.com", perm_type='user', role='writer')
Also I tried to add the recipients in a list of strings but not working
spreadSheet.share(["email1@gmail.com", "email2@gmail.com"], perm_type='user', role='writer')
@Tanaike
Tried the Pattern 2
from oauth2client.service_account import ServiceAccountCredentials
import gspread
from googleapiclient.discovery import build
scopes=[scope1, scope2]
cred=ServiceAccountCredentials.from_json_keyfile_name('myjsonfilepath', scopes)
driveClient = build("drive", "v3", credentials=cred)
emailRecepients = ['xxx', 'yyy', ,,,]
batch = driveClient.new_batch_http_request()
if len(emailRecepients) > 0 and len(emailRecepients)<=100:
for e in emailRecepients:
batch.add(driveClient.permissions().create(fileId='id', body={"role": "reader", "type": "user", "emailAddress": e}))
a = batch.execute()
print(a)