有什么方法可以只使用 Gspread 中的范围
https://www.googleapis.com/auth/spreadsheets
创建电子表格吗?
根据文档,范围本身似乎可以处理“创建”:
请建议与此问题相关的示例代码或网站
是的,您可以仅使用以下范围之一使用 Google API 创建电子表格:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/spreadsheets
来源:https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create
仅当您打算将文件保存到特定文件夹时才需要 Google Drive 权限范围。否则,您可以直接使用
https://www.googleapis.com/auth/spreadsheets
范围保存到根目录。
虽然可以在 GSpread 中传入自定义范围:
# Use one of the following, depends on your use case
gspread.oauth(scopes=['https://www.googleapis.com/auth/drive'])
gspread.service_account(scopes=['https://www.googleapis.com/auth/drive'])
来源:https://docs.gspread.org/en/latest/api/top-level.html
它使用 Google Drive API 而不是使用 Google Sheets API 创建电子表格,这就是为什么它需要
https://www.googleapis.com/auth/drive
范围