亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 gspread 創建的電子表格正在與我組織中的所有用戶共享

使用 gspread 創建的電子表格正在與我組織中的所有用戶共享

郎朗坤 2022-05-11 16:26:10
我有一個 Python 腳本,它解析 HTML 文件并將我需要的信息放入由服務帳戶創建并與我共享的 Google 表格文檔中。一切正常,除了生成的服務帳戶擁有的電子表格不僅與我共享,而且與我 G Suite 組織中的每個人共享。沒什么大不了的,因為我的組織很小,但我確信我的同事不希望這些文件弄亂他們的“與我共享”文件夾。我已經對此進行了網絡搜索并仔細閱讀了 Stack Overflow,但還沒有想出任何想法來更改我的代碼以嘗試。我還想知道這是否是我需要在 Google API 控制臺中更改的設置,但在那里也沒有找到任何東西。以下是相關代碼:import gspreadfrom oauth2client.service_account import ServiceAccountCredentialsdef loadTemplate(template_name, output_name):        # use creds to create a client to interact with the Google Drive API        print("Connecting to Google API...")        scope = ['https://www.googleapis.com/auth/drive']        creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)        client = gspread.authorize(creds)        # Make a copy of the template and name it something that uniquely identifies this report        print("Copying template...")        open_spreadsheet = client.open(template_name)        copy_spreadsheet = client.copy(open_spreadsheet.id,title=output_name, copy_permissions=True)        copy_spreadsheet.share('[email protected]', perm_type='user', role='writer', notify=False)        return copy_spreadsheettemplate_spreadsheet = loadTemplate(template_name, output_name)同樣,一切都按預期運行,除了結果與我的 G Suite 組織中的所有用戶共享,而不僅僅是與我 ([email protected]) 共享。任何建議表示贊賞!
查看完整描述

1 回答

?
揚帆大魚

TA貢獻1799條經驗 獲得超9個贊

我想通了,我覺得很愚蠢...

我正在復制模板,然后設置copy_permissions=True. 該模板實際上并未與我的整個組織共享,而是我碰巧檢查過的兩個人共享,因此默認情況下,它的每個副本都與相同的兩個人共享。更改以copy_permissions=False解決問題。


查看完整回答
反對 回復 2022-05-11
  • 1 回答
  • 0 關注
  • 220 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號