Python 使用API凭据共享Google工作表-未找到域

Python 使用API凭据共享Google工作表-未找到域,python,google-sheets,google-drive-api,gspread,Python,Google Sheets,Google Drive Api,Gspread,我是一个试图通过pythongspread访问google工作表的初学者。我遵循以下说明:https://towardsdatascience.com/accessing-google-spreadsheet-data-using-python-90a5bc214fd2 我相信我已经成功创建了我的凭证:幸存者积分-update@update-幸存者gspread.iam.gserviceaccount.com。当我试图与这封电子邮件共享google sheets文档时,我收到一封电子邮件回复,告

我是一个试图通过python
gspread
访问google工作表的初学者。我遵循以下说明:
https://towardsdatascience.com/accessing-google-spreadsheet-data-using-python-90a5bc214fd2

我相信我已经成功创建了我的凭证:
幸存者积分-update@update-幸存者gspread.iam.gserviceaccount.com
。当我试图与这封电子邮件共享google sheets文档时,我收到一封电子邮件回复,告诉我由于找不到域而无法交付。更具体地说:

DNS Error: 19491 DNS type 'mx' lookup of update-survivor-gspread.iam.gserviceaccount.com responded with code NXDOMAIN Domain name not found: update-survivor-gspread.iam.gserviceaccount.com
我找到了这个,但出现了一个
401错误:找不到OAuth客户端。

client_id=<CLIENTID_FROM_GOOGLE_DEVLOPER_CONSOLE>
redirect_uri=http://localhost:8080/
scope=https://spreadsheets.google.com/feeds
access_type=offline
response_type=code
在此范围内,我得到以下错误:

Traceback (most recent call last):
  File "<ipython-input-8-b2d4b9300652>", line 1, in <module>
    sheet = client.open(gsheet).sheet1
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\client.py", line 123, in open
    self.list_spreadsheet_files()
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\client.py", line 96, in list_spreadsheet_files
    res = self.request('get', url, params=params).json()
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\client.py", line 79, in request
    raise APIError(response)

APIError: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission: Request had insufficient authentication scopes."
   }
  ],
  "code": 403,
  "message": "Insufficient Permission: Request had insufficient authentication scopes."
 }
}
然后我得到:

Traceback (most recent call last):
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\client.py", line 123, in open
    self.list_spreadsheet_files()
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\utils.py", line 37, in finditem
    return next((item for item in seq if func(item)))

StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<ipython-input-22-b2d4b9300652>", line 1, in <module>
    sheet = client.open(gsheet).sheet1
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\client.py", line 131, in open
    raise SpreadsheetNotFound

SpreadsheetNotFound

l
是一个空列表
bk.worksheets()
返回
[]
,因此我看不到任何其他数据。

在共享此电子表格后,您是否尝试从Python代码访问此电子表格?这里有一个类似的问题:您是否可以查看并检查此解决方案是否适合您?谢谢@Burnash,感谢您的帮助。在阅读了github一期之后,我对自己的尝试做了一个全面的总结。很高兴尝试其他内容。正确的范围是
scope=['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
client.openall()
返回值与您的客户帐户如何共享?(名为“访问权限电子表格”)谢谢。以上是更多的故障排除尝试。
scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']
Traceback (most recent call last):
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\client.py", line 123, in open
    self.list_spreadsheet_files()
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\utils.py", line 37, in finditem
    return next((item for item in seq if func(item)))

StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<ipython-input-22-b2d4b9300652>", line 1, in <module>
    sheet = client.open(gsheet).sheet1
  File "C:\Users\User\Anaconda3\lib\site-packages\gspread\client.py", line 131, in open
    raise SpreadsheetNotFound

SpreadsheetNotFound
bk = client.open_by_key('1TwF6neGtogHAsqu4vjIiGWpfUPiQmVFgF5kR8k_8jC0')
sht = bk.get_worksheet(0)
l = sht.get_all_values()