Error:
Traceback (most recent call last):
File
"C:\Users\skansal\Desktop\Agile_Tool\Agile_Google_Sheets\Google_Api.py",
line 10, in
gs = gspread.authorize(credentials)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\gspread_init_.py", line 38, in authorize
client.login()
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\gspread\client.py", line 51, in login
self.auth.refresh(http)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\oauth2client\client.py", line 545, in refresh
self._refresh(http)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\oauth2client\client.py", line 749, in _refresh
self._do_refresh_request(http)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\oauth2client\client.py", line 819, in _do_refresh_request
raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: invalid_scope:
http://www.googleapis.com/auth/drive is not a valid audience string.
我确保启用了以下所有功能。
我的代码:
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
import gspread
scope = ['http://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('credential_token.json',scope)
gs = gspread.authorize(credentials)
worksheet = gc.open('Project_Sheet').sheet1
print(wks.get_all_records())
我希望能够通过python连接到Google工作表,这样我就可以在工作表上执行读取,写入和更新操作。我是python的新手。抱歉,如果我在发布问题时出错了
答案 0 :(得分:2)
答案在问题中
invalid_scope:
http://www.googleapis.com/auth/drive is not a valid audience string.
应为https://www.googleapis.com/auth/drive